'TypeError: This COM object can not automate the makepy process - please run makepy manually for this object
What this kind of error?
Traceback error
C:\Users\DELL\PycharmProjects\MyNew\venv\Scripts\python.exe
C:/Users/DELL/PycharmProjects/MyNew/agaaaaain.py
Traceback (most recent call last):
File "C:\Users\DELL\PycharmProjects\MyNew\venv\lib\site-
packages\win32com\client\gencache.py", line 530, in EnsureDispatch
ti = disp._oleobj_.GetTypeInfo()
pywintypes.com_error: (-2147418111, 'Call was rejected by callee.', None,
None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/DELL/PycharmProjects/MyNew/agaaaaain.py", line 3, in
<module>
excel = win32.gencache.EnsureDispatch('Excel.Application')
File "C:\Users\DELL\PycharmProjects\MyNew\venv\lib\site-
packages\win32com\client\gencache.py", line 541, in EnsureDispatch
raise TypeError("This COM object can not automate the makepy process -
please run makepy manually for this object")
TypeError: This COM object can not automate the makepy process - please run
makepy manually for this object
Process finished with exit code 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/DELL/PycharmProjects/MyNew/agaaaaain.py", line 3, in
<module>
excel = win32.gencache.EnsureDispatch('Excel.Application')
File "C:\Users\DELL\PycharmProjects\MyNew\venv\lib\site-
packages\win32com\client\gencache.py", line 541, in EnsureDispatch
raise TypeError("This COM object can not automate the makepy process -
please run makepy manually for this object")
TypeError: This COM object can not automate the makepy process - please run
makepy manually for this object
and this is my code
import win32com.client as win32
excel = win32.gencache.EnsureDispatch('Excel.Application')
I am using PyCharm
VirtualEnv
I didn't find any solution, any one have idea about this?
Note:How ever I am trying to use win32 to access excel
work book, as to able for modifying it!!..
Solution 1:[1]
You must consider running the code from a Virtual Environment.
And uninstall any other pywin32 module outside the Environment.
Give it a shot!
Solution 2:[2]
Encountered the same issue and resolve it by closing all running Excel applications.
Solution 3:[3]
Issue also can arise if running the line excel = win32.gencache.EnsureDispatch('Excel.Application')
more then once in your instance (AKA. a For
loop).
Solution 4:[4]
I had the same problem...was fixed in my case by adding those 2 lines:
workbook.Close(SaveChanges=True)
xl.Quit()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Arif Ali Dawood |
Solution 2 | xmubeta |
Solution 3 | Rob G |
Solution 4 | Chadee Fouad |