【发布时间】:2018-06-23 17:57:59
【问题描述】:
我尝试使用win32com Python 库进行编程以处理 PowerPoint 文件。但是,当我通过以下方式将常量传递给函数时,
new_pre.ExportAsFixedFormat(options.output,
win32com.client.constants.ppFixedFormatTypePDF,
win32com.client.constants.ppFixedFormatIntentPrint,
win32com.client.constants.msoFalse,
win32com.client.constants.ppPrintHandoutHorizontalFirst,
win32com.client.constants.ppPrintOutputSixSlideHandouts,
win32com.client.constants.msoFalse,
win32com.client.constants.ppPrintAll,
False,
False,
False,
False,
PrintRange=None
)
它引发AttributeError:
Traceback (most recent call last):
File "D:/SharedDocuments/DokyPpf/main.py", line 40, in <module>
win32com.client.constants.msoFalse,
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36\lib\site-packages\win32com\client\__init__.py", line 178, in __getattr__
raise AttributeError(a)
AttributeError: msoFalse
请注意,有一个similar question 以及可以使用的解决方案
EnsureDispatch("PowerPoint.Application")
而不是
Dispatch("")
但是,我已经使用了EnsureDispatch("PowerPoint.Application"),它仍然无法正常工作...
Here is the link对应VBA的API引用。
【问题讨论】:
-
happs = win32com.client.Dispatch("PowerPoint.Application")您无法访问您指定的服务, -
@dsgdfg 我用
app=win32com.client.EnsureDispatch("PowerPoint.Application"),有什么问题吗? -
在学会走路之前不要开始飞行!尝试正常(GUI)并查看错误,然后使用代理。
-
试试 www.pptxbuilder.com?
标签: python com ms-office powerpoint win32com