comtypes
comtypes copied to clipboard
AttributeError: module 'comtypes.gen.Word' has no attribute '_Application'
`import sys import os import comtypes.client import pythoncom import uuid import requests from docx import Document import base64 from os import listdir from os.path import isfile, join import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
bytesDoc = req.get_json().get('base')
path = '/users/echornet/pruebas/'
newFile = open(path + 'prueba.docx','wb')
newFile.write(base64.b64decode(bytesDoc))
newFile.close()
wdFormatPDF = 17
out_file = path + 'prueba.pdf'
word = comtypes.client.CreateObject('Word.Application')
doc = word.Documents.Open(newFile,ReadOnly = 1)
doc.SaveAs(out_file, FileFormat=wdFormatPDF)
doc.Close()
if bytesDoc:
return func.HttpResponse("ok")
else:
return func.HttpResponse(
"Please pass a bytes[] on the query string or in the request body",
status_code=400
)
` This code is having the error above. Any idea? I'm running the python function on an env. It creates the docx file, but no conversion is done.
@Estevete did you find solution for this issue? I'm facing the same now
Same problem here
@snoopyjc this helped me https://stackoverflow.com/a/27219913
I tried also to solve issue such way https://stackoverflow.com/a/16481091 but it didn't help me or I did something wrong.
Any news? Still facing this issue.
@Estevete @maria-matviychuk @snoopyjc @pauldamian
In the version around the time this issue was posted, each module(file) in comtypes/gen
was often generated halfway through.
So modules without definitions of the objects you wanted to use were created, then errors occurred when importing.
#300 made it fewer that partial files(modules) being generated.
Due to no recent activity, I will close this issue. If the issue remains, please re-open.