At end of my program, I am generating word file then converting this file to .pdf file format as the following:
wdFormatPDF = 17
word = comtypes.client.CreateObject('Word.Application')
doc = word.Documents.Open(resultfile)
doc.SaveAs(resultfilepdf, FileFormat=wdFormatPDF)
doc.Close()
word.Quit()
The program run properly but when I converting the
.py to .exe using pyinstaller –onefile option I get the following error when executing the .exe file.
Traceback (most recent call last):
File "C:\python\tub\test\hc.py", line 344, in <module>
word = comtypes.client.CreateObject('Word.Application')
File "C:\Users\LT440\Anaconda2\lib\site-packages\comtypes\client\__init__.py", line 250, in CreateObject
return _manage(obj, clsid, interface=interface)
File "C:\Users\LT440\Anaconda2\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
obj = GetBestInterface(obj)
File "C:\Users\LT440\Anaconda2\lib\site-packages\comtypes\client\__init__.py", line 112, in GetBestInterface
interface = getattr(mod, itf_name)
AttributeError: 'module' object has no attribute '_Application'
[4112] Failed to execute script hc
Please advice.