I\'m automating some excel related tasks which take a long time.
I\'m creating an excel instance using:
excel = win32.gencache.EnsureDispatch(\'Excel
Why don't you do it like this?
from win32com import client
excel=client.Dispatch("Excel.Application")
Here's a way to create a new instance and use static cache (which is faster and gives an ability to use kwargs):
from win32com.client import gencache
import pythoncom
clsid = "Word.Application"
clsid = pythoncom.CoCreateInstanceEx(clsid, None, pythoncom.CLSCTX_SERVER,
None, (pythoncom.IID_IDispatch,))[0]
if gencache.is_readonly:
#fix for "freezed" app: py2exe.org/index.cgi/UsingEnsureDispatch
gencache.is_readonly = False
gencache.Rebuild()
olApp = gencache.EnsureDispatch(clsid)