【发布时间】:2020-01-25 07:47:31
【问题描述】:
我正在尝试使用 python 3 与用于 powerpoint 的自定义加载项进行交互。特别是 think-cell,一种图表工具。我只需要使用此处记录的一个函数:https://www.think-cell.com/en/support/manual/exceldataautomation.shtml
我可以成功使用 pywin32 连接到 powerpoint 并获得对插件的引用
import win32com.client as win32
def ppt():
return win32.gencache.EnsureDispatch('PowerPoint.Application')
def excel():
return win32.gencache.EnsureDispatch('Excel.Application')
e = excel()
p = ppt()
thinkcell = p.COMAddIns("thinkcell.addin").Object
但是,当我调用 thinkcell.UpdateChart(slide, "Chart24", r)(幻灯片和 r 在别处定义)时,我得到:
AttributeError: <unknown>.UpdateChart.
我认为这意味着问题在于没有为 think-cell 插件编写 Python 接口,或者插件未以对象可以调用其函数的方式注册。
我该如何解决这个问题?如果我需要编写一个允许调用 UpdateChart 的接口,那会是什么样子?
【问题讨论】: