以下代码供参考: '* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2006-11-20 18:40:31 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0102^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Option Explicit Sub Example() '运行本代码前请新更新目录域 Dim myTableContent As TableOfContents, oField As Field Dim strField As String, myStyle As String, myRange As Range Dim N As Integer, ColId As Byte, myPage As String On Error GoTo ErrHandle With ActiveDocument If .TablesOfContents.Count < 1 Then Exit Sub Application.ScreenUpdating = False '关闭屏幕更新 myStyle = "标题 1" '此处设置需要加入作者的段落样式,通常应为第一标题级别 Set myTableContent = .TablesOfContents(1) '定义为活动文档的第一个目录 For Each oField In myTableContent.Range.Fields '在目录所有区域中域中循环 strField = VBA.UCase(oField.Code.Text) '取得域代码的大写(统一,以便后续处理) If VBA.InStr(strField, " HYPERLINK \L") > 0 Then '如果含有指定字符 strField = VBA.Replace(strField, " HYPERLINK \L ", "") '删除该指定文本 strField = VBA.Replace(strField, " ", "") '删除空格 strField = VBA.Replace(strField, """", "") '删除半角引号 Set myRange = .Bookmarks(strField).Range myRange.SetRange myRange.Start, myRange.Start |