Python xlwings pywintypes.com_error

2022/06/19 22:49


Xlwings pywintypes.com_error: (-2147352567, ‘Exception occurred.’, (0, None, None, None, 0, -2147352565), None)

Traceback (most recent call last):
  File "H:\PythonProject\name_data\", line 31, in <module>
    xw.Book(workbook_path).sheets[sheet_name].range("A" + str(row_num),
  File "C:\Users\Eddy\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\", line 83, in __getitem__
    return self(key)
  File "C:\Users\Eddy\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\", line 4314, in __call__
    return Sheet(impl=self.impl(name_or_index))
  File "C:\Users\Eddy\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\", line 617, in __call__
    return Sheet(xl=self.xl(name_or_index))
  File "C:\Users\Eddy\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\", line 160, in __call__
    v = self._inner(*args, **kwargs)
  File "C:\Users\Eddy\AppData\Local\Programs\Python\Python39\lib\site-packages\win32com\gen_py\", line 36625, in __call__
    ret = self._oleobj_.InvokeTypes(0, LCID, 2, (9, 0), ((12, 1),),Index
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None)


If you got this error, the reason is probably du to the Excel path or sheet name is  not right. Just check your Excel path or sheet name.

Leave a Reply

Back to top