I am trying tot compile a Python 3.3 program that uses COM to interact with MS Word. The interpreted version of the program runs OK and brings up MS word.
word =win32com.client.gencache.EnsureDispatch(u"Word.Application")
doc = word.Documents.Add()
word.Visible = True
Running makepy for Microsoft Word 14.0 Object Library(8.5) gives me the reference key 00020905-0000-0000-C000-000000000046.
Now when the program is compiled with py2exe, the compiled program dies saying:
Traceback (most recent call last): File "main.py", line 17, in <module>
File "C:\Python 3.3.5\lib\site-packages\win32com\client\gencache.py", line 544, in EnsureDispatch
disp_class = CLSIDToClass.GetClass(str(disp_clsid))
File "C:\Python 3.3.5\lib\site-packages\win32com\client\CLSIDToClass.py", line 46, in GetClass
return mapCLSIDToClass[clsid] KeyError: '{00020970-0000-0000-000-000000000046}'
Now what is interesting is that the key this error gives to me is different from the key makepy finds. Searching the internet I found as a possible solution that the registry is messed up. That however would explain a failure from BOTH situations (i.e. interpreted AND compiled) whereas my problem is restricted to the compiled version. I also wondered whether there might be a 32/64bit problem but my python toolchain in 32 bit as far as I know. I have tried:
py2exe setup scripts with and without typelibs as py2exe options
cleaning up genpy (in both the temp dir and the python sitepackages
win32com client dir)
I look forward to your advise on this one.