Cross Referencing


InsertCrossReference

Inserts a cross-reference to a heading, numbered item, bookmark, footnote, or endnote
Can also be used to insert a cross-reference to an item that has a caption label (for example, an equation, figure, or table).

Selection.InsertCrossReference ReferenceType:=WdReferenceType.wdRefTypeNumberedItem, _ 
                               ReferenceKind:=WdReferenceKind.wdNumberNoContext, _
                               ReferenceItem:=1, _
                               InsertAsHyperlink:=True, _
                               IncludePosition:=False, _
                               SeparateNumbers:=False, _
                               SeparatorString:=" "

ReferenceType - 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 - The information to be included in the cross-reference.
If you specify wdPageNumber for the value of ReferenceKind, you may need to repaginate the document to see the correct cross-reference information.
ReferenceItem - 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 box 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) default is True to insert the cross-reference as a hyperlink.
IncludePosition - (Optional) default is True to insert "above" or "below," depending on the location of the reference item in relation to the cross-reference.
SeparateNumbers - (Optional) 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) Specifies the string to use as a separator if the SeparateNumbers parameter is set to True.


Selection.InsertCrossReference ReferenceType:="Numbered item", _ 
                               ReferenceKind:=WdReferenceKind.wdNumberRelativeContext, _
                               ReferenceItem:="2", _
                               InsertAsHyperlink:=True,
                               IncludePosition:=False,
                               SeparateNumbers:=False, _
                               SeparatorString:=" "

Selection.InsertCrossReference ReferenceType:="Heading", _ 
                               ReferenceKind:=WdReferenceKind.wdContentText, _
                               ReferenceItem:="2", _
                               InsertAsHyperlink:=True,
                               IncludePosition:=False,
                               SeparateNumbers:=False, _
                               SeparatorString:=" "

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


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrev