pywin32
pywin32 copied to clipboard
"win32com.client.gencache.EnsureDispatch" doesn't work on office 64bit
I'm using python 3.8 64 bit on windows 10 64bit , my excel is office365 64bit and office 2016 64bit, pywin32 is 228.
when I use win32com.client.gencache.EnsureDispatch('Excel.Application') , it raises error as fallows:
`d:\miniconda3\lib\site-packages\win32com\client\build.py in _ResolveType(typerepr, itypeinfo) 449 try: --> 450 resultTypeInfo = itypeinfo.GetRefTypeInfo(subrepr) 451 except pythoncom.com_error as details:
com_error: (-2147319765, '找不到元素。', None, None)
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
d:\miniconda3\lib\site-packages\win32com\client\gencache.py in EnsureDispatch(prog_id, bForDemand) 539 disp = disp_class(disp.oleobj) 540 except pythoncom.com_error: --> 541 raise TypeError("This COM object can not automate the makepy process - please run makepy manually for this object")
542 return disp
543
TypeError: This COM object can not automate the makepy process - please run makepy manually for this object`
when I run makepy manually , there is no 'excel 16.0 object library' to choose.
I am facing the same error. How do you run makepy manually?
Bumping this up! Can someone please answer this. I'm sure a lot of people are facing this issue. @mhammond
Don't use win32com.client.gencache.EnsureDispatch, using win32com.client.Dispatch can fix this issue.
You can use, import win32com.client as win32 xlApp = win32.Dispatch('Excel.Application')
It works for me.