Search code examples
pythonpython-3.xdocx2pdf

Python docx2pdf Convert Com_Error


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:\Users\username\word_automation\example.py", line 372, in  convert("C:/Users/username/word_automation/")
File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\docx2pdf_init_.py", line 106, in convert return windows(paths, keep_active)
File "C:\Users\username\AppData\Roaming\Python\Python39\site-packages\docx2pdf_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.


Solution

  • 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.