I've been trying to convert old .doc files to PDFs using Python, but I have been running into some trouble. Here is my code:
import os
import comtypes.client
format_code = 17
file_input = os.path.abspath('(1)2014-06-18.doc')
file_output = os.path.abspath('test.pdf')
word_app = comtypes.client.CreateObject('Word.Application')
word_file = word_app.Documents.Open(file_input)
word_file.SaveAs(file_output,FileFormat=format_code)
word_file.Close()
word_app.Quit()
Whenever I execute it, I get:
Users/gawel/OneDrive/Desktop/scraping/doctotxt.py
Traceback (most recent call last):
File "c:/Users/gawel/OneDrive/Desktop/scraping/doctotxt.py", line 10, in <module>
word_file.SaveAs(file_output,FileFormat=format_code)
_ctypes.COMError: (-2147418111, 'Call was rejected by callee.', (None, None, None, 0, None))
I have been trying to do some research on what this error could be mean, but I have been unsuccessful. Any help would be appreciated. Thanks!