Share via


GetCrossReferenceItems Method

Returns an array of items that can be cross-referenced based on the specified cross-reference type. The array corresponds to the items listed in the For which box in the Cross-reference dialog box (Insert menu).

Note  An item returned by this method can be used as the ReferenceWhich argument for the InsertCrossReference method.

expression**.GetCrossReferenceItems(ReferenceType)**

expression Required. An expression that returns one of the objects in the Applies To list.

WdReferenceType

Can be one of the following WdReferenceType constants.

wdRefTypeBookmark

wdRefTypeEndnote

wdRefTypeFootnote

wdRefTypeHeading

wdRefTypeNumberedItem.

Example

This example displays the name of the first bookmark in the active document that can be cross-referenced.

If ActiveDocument.Bookmarks.Count >= 1 Then
    myBookmarks = ActiveDocument.GetCrossReferenceItems( _
        wdRefTypeBookmark)
    MsgBox myBookmarks(1)
End If

This example uses the GetCrossReferenceItems method to retrieve a list of headings that can be cross-referenced and then inserts a cross-reference to the page that includes the heading "Introduction."

myHeadings = _
    ActiveDocument.GetCrossReferenceItems(wdRefTypeHeading)
For i = 1 To Ubound(myHeadings)
    If Instr(LCase$(myHeadings(i)), "introduction") Then 
        Selection.InsertCrossReference _
            ReferenceType:=wdRefTypeHeading, _
            ReferenceKind:=wdPageNumber, ReferenceItem:=i
        Selection.InsertParagraphAfter
    End If
Next i

Applies to | Document Object

See Also | InsertCrossReference Method