pywin32 icon indicating copy to clipboard operation
pywin32 copied to clipboard

"win32com.client.gencache.EnsureDispatch" doesn't work on office 64bit

Open tsiank opened this issue 4 years ago • 3 comments

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) in ----> 1 win32.gencache.EnsureDispatch('Excel.Application')

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.

tsiank avatar Aug 01 '20 12:08 tsiank

I am facing the same error. How do you run makepy manually?

diallobakary4 avatar Oct 21 '20 07:10 diallobakary4

Bumping this up! Can someone please answer this. I'm sure a lot of people are facing this issue. @mhammond

sahilpurav avatar Sep 19 '22 08:09 sahilpurav

Don't use win32com.client.gencache.EnsureDispatch, using win32com.client.Dispatch can fix this issue.

johnnysluckydays avatar Sep 20 '22 02:09 johnnysluckydays

You can use, import win32com.client as win32 xlApp = win32.Dispatch('Excel.Application')

It works for me.

JanviSavani avatar Mar 27 '23 12:03 JanviSavani