|
就附件格式而言,可试试如下代码:- Sub test()
- '插入对插入点所属标题编号的交叉引用
- Dim strRefitems() As String
- Dim ref
- Dim i As Integer
- Dim strList As String
- strRefitems = ActiveDocument.GetCrossReferenceItems(wdRefTypeNumberedItem)
- If UBound(strRefitems) = 0 Then Exit Sub
- With Selection
- If .StoryType = wdMainTextStory Then
- strList = .Bookmarks("\headinglevel").Range.ListFormat.ListString
- ElseIf .StoryType = wdTextFrameStory Then
- strList = .ShapeRange(1).Anchor.GoTo(wdGoToHeading, wdGoToPrevious).ListFormat.ListString
- End If
- For Each ref In strRefitems
- i = i + 1
- If Split(Trim(ref), Chr(32))(0) = Trim(strList) Then
- .InsertCrossReference wdRefTypeNumberedItem, wdNumberNoContext, i, True
- Exit For
- End If
- Next
- End With
- End Sub
复制代码 |
|