【发布时间】:2020-10-13 20:56:20
【问题描述】:
''' 当我使用下面的代码时,它可以在创建它的文档中使用。如果我更改文件,它会失败。有谁知道为什么? '''
'
Sub AddTOC() 'Need to find how to stop going in error on doc change
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=0
Application.Templates( _
"C:\Users\Sean Celestin\AppData\Roaming\Microsoft\Document Building Blocks\1033\16\Built-In
Building Blocks.dotx" _
).BuildingBlockEntries("Automatic Table 1").Insert Where:=Selection.Range _
, RichText:=True
Selection.InsertBreak Type:=wdPageBreak
End Sub
'
【问题讨论】:
标签: vba ms-word tableofcontents