I am trying to convert from multiple docx files to multiple pdf files. But in the process I got an error (image below). I turned off the word application in the task manager and converted the file manually but still failed, the dialog sent me the message: "Export failed due to an unexpected error".
My code here:
import os
from docx2pdf import convert
import time
path = "C:/Users/thuandao2/Desktop/test"
extension = [".docx", ".doc"]
for root, dirs, files in os.walk(path):
for file in files:
ext = os.path.splitext(file)[-1].lower()
f_name = os.path.splitext(file)[0]
if ext in extension:
if "~" not in f_name:
print("\nCovert " + str(file) + " to pdf: ")
convert(os.path.join(root, file))
time.sleep(5)
I used lib docx2pdf to covert. I think there is something wrong with my docx file which leads to the error but I don't know what it is.
I have also investigated on google and it seems this problem is very hard to detect root cause. I have found this link:
