OS (e.g. Windows 10 or macOS Sierra)
Windows 10
Versions of xlwings, Excel and Python (e.g. 0.11.8, Office 365, Python 3.7)
Python 3.6.5
xlwings==0.15.0
Excel 2016 MSO (16.0.4639.1000)
Describe your issue (incl. Traceback!)
When I try to use the @xlwings.sub decorator, I get this error message when I try to run the macro in Excel. The @xlwings.func seems to work fine.
# Your traceback here
pythoncom error: Python error invoking COM method.
Traceback (most recent call last):
File "E:\CODE\.virtualenvs\shifts\lib\site-packages\win32com\server\policy.py", line 278, in _Invoke_
return self._invoke_(dispid, lcid, wFlags, args)
File "E:\CODE\.virtualenvs\shifts\lib\site-packages\win32com\server\policy.py", line 283, in _invoke_
return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None)
File "E:\CODE\.virtualenvs\shifts\lib\site-packages\win32com\server\policy.py", line 586, in _invokeex_
return func(*args)
File "E:\CODE\.virtualenvs\shifts\lib\site-packages\xlwings\server.py", line 198, in CallUDF
res = call_udf(script, fname, args, this_workbook, FromVariant(caller))
File "E:\CODE\.virtualenvs\shifts\lib\site-packages\xlwings\udfs.py", line 246, in call_udf
xw_caller.sheet.book.name + xw_caller.sheet.name + xw_caller.address.split(':')[0])
File "E:\CODE\.virtualenvs\shifts\lib\site-packages\xlwings\main.py", line 1086, in sheet
return Sheet(impl=self.impl.sheet)
File "E:\CODE\.virtualenvs\shifts\lib\site-packages\xlwings\_xlwindows.py", line 697, in sheet
return Sheet(xl=self.coords[0])
File "E:\CODE\.virtualenvs\shifts\lib\site-packages\xlwings\_xlwindows.py", line 683, in coords
self.xl.Worksheet,
AttributeError: 'int' object has no attribute 'Worksheet'
Include a minimal code sample to reproduce the issue (and attach a sample workbook if required!)
# Your code here
@xw.sub
def get_workbook_name():
"""Writes the name of the Workbook into Range("D3") of Sheet 1"""
wb = xw.Book.caller()
wb.sheets['Sheet1'].range('D3').value = wb.name
OS (e.g. Windows 10 or macOS Sierra)
Windows 10
Versions of xlwings, Excel and Python (e.g. 0.11.8, Office 365, Python 3.7)
Python 3.6.5
xlwings==0.15.0
Excel 2016 MSO (16.0.4639.1000)
Describe your issue (incl. Traceback!)
When I try to use the @xlwings.sub decorator, I get this error message when I try to run the macro in Excel. The @xlwings.func seems to work fine.
Include a minimal code sample to reproduce the issue (and attach a sample workbook if required!)