import win32com.client
#open win32 client in hidden mode
word = win32com.client.Dispatch("Word.Application")
word.Visible = False
word.DisplayAlerts = False #tried setting this to False and 0 to suppress dialog. didn't work
pdf_path = r"C:\path\to\pdf"
doc_path = r"C:\path\to\docx"
#open pdf doc with client
pdf_doc = word.Documents.Open(pdf_path)
#convert pdf to docx
pdf_doc.SaveAs2(doc_path, FileFormat=16) #16 is the file format for docx. tried running this with pdf_doc.SaveAs. didn't work.
pdf_doc.Close() #also tried running this as pdf_doc.Close(False). didn't work
word.Quit()
改变
pdf_doc = word.Documents.Open(pdf_path)
pdf_doc = word.Documents.Open(pdf_path, False, False, False)