用VBA吧! 先手动更新目录,再运行以下代码: '* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2006-10-15 6:52:18 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0079^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Option Explicit
Sub Example() Dim myTableContent As TableOfContents, oField As Field Dim strField As String, AuthorStyle As String, Authors As Variant Dim N As Integer On Error GoTo ErrHandle With ActiveDocument If .TablesOfContents.Count < 1 Then Exit Sub Application.ScreenUpdating = False '关闭屏幕更新 AuthorStyle = "标题 1" '此处设置需要加入作者的段落样式,通常应为第一标题级别 Authors = Array("赵", "钱", "孙", "李", "周", "吴") '此处键入所有作者名,应与第一标题级别数量吻合 Set myTableContent = .TablesOfContents(1) '定义为活动文档的第一个目录
|