如何解决Python: Word to Pdf 错误 (OSError: [WinError -2147221005] Invalid class string )
我正在尝试使用此代码将 word 文件转换为 pdf 文件:但它给了我这个无法理解的错误(OSError: [WinError -2147221005] Invalid class string)我检查了这个 answer 但我没有不明白答案
import os
import comtypes.client
wdFormatPDF = 17
in_file = os.path.abspath("C:\\Users\\somename\\Desktop\\tests\\sad.doc")
out_file = os.path.abspath("C:\\Users\\somename\\Desktop\\tests\\sad.pdf")
word = comtypes.client.CreateObject('Word.Application')
doc = word.Documents.Open(in_file)
doc.SaveAs(out_file,FileFormat=wdFormatPDF)
doc.Close()
word.Quit()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。