I'm running a python script in visual studio code, I have run the code before and it's worked fine. Today is the first time running it in a couple of weeks and now I am getting this error message come up:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:/Users/XXXX/Documents/XXXX/XXXX/Plaxis/v1.44/AutoPlx - PB - 1.44.py", line 4640, in <module>
ex = win32.dynamic.Dispatch('Excel.Application')
File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 127, in Dispatch
IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch,userName,clsctx)
File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147024703, 'OLE error 0x800700c1', None, None)
(base) PS C:\Users\XXXX\Documents\XXXX\XXXX\Plaxis\v1.44>
The error message is specific to a code which I'm using, I have run other codes today which have worked fine. The code which produces the error is used in conjunction with another programme called Plaxis (geotechnical modelling). The code reads an excel file with geometry, soil conditions etc and then builds the model in Plaxis. When I run the script it allows me to select the excel file and finds which analysis I want to run. But returns the error when it calls on dynamic.py
def _GetGoodDispatch(IDispatch, clsctx = pythoncom.CLSCTX_SERVER):
# quick return for most common case
if isinstance(IDispatch, PyIDispatchType):
return IDispatch
if isinstance(IDispatch, _GoodDispatchTypes):
try:
IDispatch = pythoncom.connect(IDispatch) #FAILS ON THIS LINE
except pythoncom.ole_error:
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
else:
# may already be a wrapped class.
IDispatch = getattr(IDispatch, "_oleobj_", IDispatch)
return IDispatch
This is when the error is returned:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)
I haven't tried this outside of Visual Studio
I'm very new when it comes to coding/ python so any help on this would be appreciated. Cheers
User contributions licensed under CC BY-SA 3.0