我使用Windows和Jupyter编写python代码,当我使用package时comtypes.客户端,它不稳定,有时有效,有时不工作。我正在做的是尝试将pptx文件转换为pdf文件。这是我的代码:
import comtypes.client
def PPTtoPDF(inputFileName, outputFileName, formatType = 32):
powerpoint = comtypes.client.CreateObject("Powerpoint.Application")
powerpoint.Visible = 1
if outputFileName[-3:] != 'pdf':
outputFileName = outputFileName + ".pdf"
deck = powerpoint.Presentations.Open(inputFileName)
deck.SaveAs(outputFileName, formatType) # formatType = 32 for ppt to pdf
deck.Close()
powerpoint.Quit()
PPTtoPDF('07-20 contact PPT.pptx','./Reports/07-20 contact result',32)
错误是:
^{pr2}$我不认为这段代码有什么问题,因为它运行了好几次,所以可能是因为计算机环境或其他原因。有谁能告诉我如何使代码稳定,或者有更好的方法将PPTX转换成python中的PDF?在
谢谢大家~
我收到了同样的错误,我有一台64位的Windows PC。我的解决方案包括使用以下命令指定文件路径:
相关问题 更多 >
编程相关推荐