Issue to use xlwings through windows remote management

86 Views Asked by At

I was trying to run a python script which contains command like this:

wb = xw.Book(r'C:/Users/myUser/Documents/scripts/Analyzer.xlsm')

when I run this python script in windows powershell terminal and through windows remote management in windows 10, it can be run without any issue.

However, after my PC upgrade to windows 11, even I get no error run it through terminal, when I run it through windows remote management, It would give error like:

Traceback (most recent call last):
   File "C:\Users\myUser\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\_xlwindows.py", line 711, in __call__
     return Book(xl=self.xl(name_or_index))
   File "C:\Users\myUser\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\_xlwindows.py", line 219, in __call__
     v = self._inner(*args, **kwargs)
   File "C:\Users\myUser\AppData\Local\Temp\gen_py\3.9\00020813-0000-0000-C000-000000000046x0x1x9.py", line 41316, in __call__
     ret = self._oleobj_.InvokeTypes(0, LCID, 2, (13, 0), ((12, 1),),Index
 pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None)
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "C:\Users\myUser\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\main.py", line 4963, in open
     impl = self.impl(name)
   File "C:\Users\myUser\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\_xlwindows.py", line 713, in __call__
     raise KeyError(name_or_index)
 KeyError: 'Analyzer.xlsm'
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "C:\Users\myUser\Documents\script\macro_new.py", line 92, in 
     wb = xw.Book(r'C:/Users/myUser/Documents/scripts/Analyzer.xlsm')
   File "C:\Users\myUser\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\main.py", line 898, in __init__
     impl = app.books.open(
   File "C:\Users\myUser\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\main.py", line 4970, in open
     impl = self.impl.open(
   File "C:\Users\myUser\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\_xlwindows.py", line 745, in open
     xl=self.xl.Open(
   File "C:\Users\myUser\AppData\Local\Programs\Python\Python39\lib\site-packages\xlwings\_xlwindows.py", line 105, in __call__
     v = self.__method(*args, **kwargs)
   File "C:\Users\myUser\AppData\Local\Temp\gen_py\3.9\00020813-0000-0000-C000-000000000046x0x1x9.py", line 41193, in Open
     ret = self._oleobj_.InvokeTypes(1923, LCID, 1, (13, 0), ((8, 1), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17), (12, 17)),Filename
 pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel', "Microsoft Excel cannot access the file 'C:\\Users\\myUser\\Documents\\script\\Analyzer.xlsm'. There are several possible reasons:\n\n� The file name or path does not exist.\n� The file is being used by another program.\n� The workbook you are trying to save has the same name as a currently open workbook.", 'xlmain11.chm', 0, -2146827284), None)

I update the xlwings version to xlwings-0.30.4, it doesn't help the python environment in my PC is 3.9.13

0

There are 0 best solutions below