【发布时间】:2021-05-11 20:37:20
【问题描述】:
我正在尝试使用 python 运行 MS-word VBA 宏,但我不断收到错误消息。
import win32com.client as win32
WrdApp = win32.GetActiveObject("Word.Application")
#Call current file
WrdDoc = WrdApp.ActiveDocument
#Insert Caption
WrdApp.Selection.InsertCaption(Label='number')
#^This line gives the error
错误信息
com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Word', 'Command failed', 'wdmain11.chm', 36966, -2146824090), None)
任何熟悉 Python 和 MS-word 宏的人都可以告诉我为什么会出现这个错误?
【问题讨论】:
标签: python ms-word macros win32com