Reputation: 1159
When I try to connect to an existing workbook and verify that the connection works, like so:
import xlwings as xw
wb = xw.Workbook('/users/edchigliak/sites/xlwings/htz/google/sem_google_realizacija_2016.xlsm')
print(wb.sheet(1).name)
terminal on Mac OSX Yosemite throws this error:
OSERROR: -1728 MESSAGE: The object you are trying to access does not exist
COMMAND: app(u'/Applications/MicrosoftExcel.app').workbooks['sem_google_realizacija_2016.xlsm'].name.get()
Workbook does get opened, it prompts for a permission to enable macros and data connections, so all is well there. It seems to me as if I am trying to call a .name() method (or property?) on MicrosoftExcel.app instead of from xlwings library?
What I ultimately wish to do (to go through the whole process):
Please advise how I can go about this.
Upvotes: 0
Views: 1988
Reputation: 7070
First make sure you've got the path right, e.g. try to run open /users/edchigliak/sites/xlwings/htz/google/sem_google_realizacija_2016.xlsm
in your Terminal to see if it opens correctly.
Second, you've got the syntax wrong for the sheet. It should be like this:
import xlwings as xw
wb = xw.Workbook(...)
print(xw.Sheet(1).name)
Note that it automatically refers to the last instantiated Workbook. If you want to explicitly specify the workbook, you currently need to do it like this:
xw.Sheet(1, wkb=wb).name
But this syntax might be revised in the nearer future.
Upvotes: 1