Python docx2pdf Convert Com_Error

Question:

I want to convert 2 docx files (which are in same path) in same code.
Yesterday it was working. But today i have an error. Still it’s working, it convert files but it stop the code on that cell ”’docx2pdf.convert(path)”’ and i have different codes after it, code must continue.
I didn’t change anything.

Error is:

**0%| | 0/4 [00:00<?, ?it/s]
Traceback (most recent call last):
File "C:Usersusernameword_automationexample.py", line 372, in  convert("C:/Users/username/word_automation/")
File "C:UsersusernameAppDataRoamingPythonPython39site-packagesdocx2pdf_init_.py", line 106, in convert return windows(paths, keep_active)
File "C:UsersusernameAppDataRoamingPythonPython39site-packagesdocx2pdf_init_.py", line 25, in Windows doc = word.Documents.Open(str(docx_filepath))
File "<COMObject >", line 5, in Open
com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Word', 'Dosya bozuk görünüyor.', 'wdmain11.chm', 25272,-2146822496), None)**

How can i fix this?

Thanks for your help.

Asked By: enesert

||

Answers:

-2146822496 is 0x800A16A0, which is "the file appears to be damaged". If you can open this file in Word, try doing a "save as" and replacing the original.

Answered By: Tim Roberts

I solved the error.

My program makes new word files from another word files. And one of the new word file left a hidden broken word file which name is $new.docx. And i can’t see it even open hidden files.

I searched it and i saw, i should write to cmd attrib -h -r -s /s /d C:*.* for be appear hidden files. And in programs folder, it appeared.

I deleted it, error fixed.

Answered By: enesert
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.