我正在尝试用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宏的人都可以告诉我为什么会出现此错误
如果要在标签中使用除“等式”、“图形”、“表格”或WdCaptionLabelID以外的其他标签,则必须定义新标签(请参见https://docs.microsoft.com/en-us/office/vba/api/word.selection.insertcaption、https://docs.microsoft.com/en-us/office/vba/api/word.captionlabels):
相关问题 更多 >
编程相关推荐