title | keywords | f1_keywords | api_name | ms.assetid | ms.date | ms.localizationpriority | ||
---|---|---|---|---|---|---|---|---|
Range.InsertCrossReference method (Word) |
vbawd10.chm157155746 |
|
|
5899db5b-254c-17ac-4c4b-943a5a5b44cb |
06/08/2017 |
medium |
Inserts a cross-reference to a heading, bookmark, footnote, or endnote, or to an item for which a caption label is defined (for example, an equation, figure, or table).
expression. InsertCrossReference
( _ReferenceType_
, _ReferenceKind_
, _ReferenceItem_
, _InsertAsHyperlink_
, _IncludePosition_
, _SeparateNumbers_
, _SeparatorString_
)
expression Required. A variable that represents a Range object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
ReferenceType | Required | Variant | The type of item for which a cross-reference is to be inserted. Can be any WdReferenceType or WdCaptionLabelID constant or a user defined caption label. |
ReferenceKind | Required | WdReferenceKind | The information to be included in the cross-reference. |
ReferenceItem | Required | Variant | If ReferenceType is wdRefTypeBookmark, this argument specifies a bookmark name. For all other ReferenceType values, this argument specifies the item number or name in the Reference type option in the Cross-reference dialog box. Use the GetCrossReferenceItems method to return a list of item names that can be used with this argument. |
InsertAsHyperlink | Optional | Variant | True to insert the cross-reference as a hyperlink to the referenced item. |
IncludePosition | Optional | Variant | True to insert "above" or "below," depending on the location of the reference item in relation to the cross-reference. |
SeparateNumbers | Optional | Variant | True to use a separator to separate the numbers from the associated text. (Use only if the ReferenceType parameter is set to wdRefTypeNumberedItem and the ReferenceKind parameter is set to wdNumberFullContext.) |
SeparatorString | Optional | Variant | Specifies the string to use as a separator if the SeparateNumbers parameter is set to True. |
If you specify wdPageNumber for the value of ReferenceKind, you may need to repaginate the document to see the correct cross-reference information.
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
[!includeSupport and feedback]