InsertCrossReference Method Example

This example inserts at the beginning of the active document a cross-reference to the page that includes the first bookmark in the document.

Set myRange = ActiveDocument.Range(Start:=0, End:=0)
myBookmarks = ActiveDocument _
    .GetCrossReferenceItems(wdRefTypeBookmark)
With myRange
    .InsertBefore "Page "
    .Collapse Direction:=wdCollapseEnd
    .InsertCrossReference ReferenceType:=wdRefTypeBookmark, _
        ReferenceKind:=wdPageNumber, ReferenceItem:=myBookmarks(1)
End With

This example inserts a sentence that contains two cross-references: one cross-reference to heading text, and another one to the page where the heading text appears.

With Selection
    .Collapse Direction:=wdCollapseStart
    .InsertBefore "For more information, see "
    .Collapse Direction:=wdCollapseEnd
    .InsertCrossReference ReferenceType:=wdRefTypeHeading, _
        ReferenceKind:=wdContentText, ReferenceItem:=1
    .InsertAfter " on page "
    .Collapse Direction:=wdCollapseEnd
    .InsertCrossReference ReferenceType:=wdRefTypeHeading, _
        ReferenceKind:=wdPageNumber, ReferenceItem:=1
    .InsertAfter "."
End With