0

I have two versions of excel in my Windows machine: 2010 and 2013, the defaulted version in windows is 2013, (which I tend not to use do to incompatibilities with some old macros), when I use xlwings to open an excel file, it does in the 2013 version, how can I tell xlwings to use the 2010 version instead?

This is my code:

import xlwings as xw
wb = xw.Book('FileName.xlsx')

Thanks in advance for your help and comments!

Pegaso
  • 115
  • 2
  • 13
  • Uninstall Excel 2013, that should fix the registry entry. Seriously - I don't think you can. – Mathieu Guindon Jan 08 '18 at 20:37
  • Unfortunately: "Uninstall Excel 2013, that should fix the registry entry. Seriously - I don't think you can. – Mat's Mug 17 mins ago" is not an option... – Pegaso Jan 08 '18 at 20:55
  • The bigger question would be *why* do you want to open it in Excel 2010 and *exactly* what's wrong with your code for it to break in 2013. Fix your code, it should be easier to fix than Windows. – Mathieu Guindon Jan 08 '18 at 20:59
  • `HKEY_CLASSES_ROOT\Excel.Application.11` Each excel has it's own app object. `HKEY_CLASSES_ROOT\Excel.Application` has a `CurVer` key under it pointing it to a specific excel app.If using `GetObject` you can specify which class to use as the second parameter. – ACatInLove Jan 08 '18 at 21:27
  • Changing the Curver didn't make any difference, (I rebooted to be sure the registry took the changes). It was pointing to 15, so I replaced by 14. – Pegaso Jan 08 '18 at 21:52
  • @Mat's Mug Nothing wrong with the code, this works fine in any of the two versions, but I prefer the older version, I had problems with some old macros in 2013. Thanks for your comments – Pegaso Jan 08 '18 at 21:54
  • if you have a problem with he excel installation with `xlwings`, it might be possible to use another library to access your files. I was just testing https://openpyxl.readthedocs.io/en/latest/index.html# to read very large files and worked fine for my purposes, but ended using ´readxl` in R thanks to this QA https://stackoverflow.com/questions/6099243/read-an-excel-file-directly-from-a-r-script – Marco Jan 08 '18 at 22:37
  • That's because you are early binding. Get the right references in your PYTHON. – ACatInLove Jan 08 '18 at 22:46
  • @Marco I need to call a Python function from excel, would openpyxl do that? Thanks! – Pegaso Jan 08 '18 at 23:03
  • @Pegaso, I do not know it at all, I was opening excel from Python and reading data. I read it could also create excel files and write cells on them or in existing ones from Python, but you are not just calling a Python function from excel, you have an object which is a workbook. What do you want to do with it? – Marco Jan 08 '18 at 23:14
  • On Windows, if you want to change the version of Excel that xlwings talks to, go to Control `Panel > Programs and Features` and Repair the Office version that you want as default. – Felix Zumstein Jan 08 '18 at 23:42
  • As you are not using CreateObject/GetObject then you are early binding. – ACatInLove Jan 09 '18 at 00:46

0 Answers0