InsertCrossReference 方法(Word)Range.InsertCrossReference method (Word)

插入对标题、书签、脚注、尾注或定义了题注标签的项(如公式、图表或表格)的交叉引用。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).


expressionexpression. InsertCrossReference( _ReferenceType_ , _ReferenceKind_ , _ReferenceItem_ , _InsertAsHyperlink_ , _IncludePosition_ , _SeparateNumbers_ , _SeparatorString_ )InsertCrossReference( _ReferenceType_ , _ReferenceKind_ , _ReferenceItem_ , _InsertAsHyperlink_ , _IncludePosition_ , _SeparateNumbers_ , _SeparatorString_ )

expression:必需。expression Required. 一个代表 Range 对象的变量。A variable that represents a Range object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
ReferenceTypeReferenceType 必需Required VariantVariant 为要插入交叉引用的项的类型。The type of item for which a cross-reference is to be inserted. 可以是任何WdReferenceTypeWdCaptionLabelID常量或用户定义的题注标签。Can be any WdReferenceType or WdCaptionLabelID constant or a user defined caption label.
ReferenceKindReferenceKind 必需Required WdReferenceKindWdReferenceKind 要包含在交叉引用中的信息。The information to be included in the cross-reference.
ReferenceItemReferenceItem 必需Required VariantVariant 如果 ReferenceType 是 wdRefTypeBookmark ,该参数指定的书签名称。If ReferenceType is wdRefTypeBookmark, this argument specifies a bookmark name. 对于所有其他 ReferenceType 值,此参数在 交叉引用对话框中的 引用类型选项中指定物料编号或名称。For all other ReferenceType values, this argument specifies the item number or name in the Reference type option in the Cross-reference dialog box. 使用 GetCrossReferenceItems 方法返回可与此参数一起使用的项名称的列表。Use the GetCrossReferenceItems method to return a list of item names that can be used with this argument.
InsertAsHyperlinkInsertAsHyperlink 可选Optional VariantVariant 要插入交叉引用作为超链接引用的项。True to insert the cross-reference as a hyperlink to the referenced item.
IncludePositionIncludePosition 可选Optional VariantVariant True 则根据引用项相对于交叉引用的位置插入"见上方"或"见下方,"。True to insert "above" or "below," depending on the location of the reference item in relation to the cross-reference.
SeparateNumbersSeparateNumbers 可选Optional VariantVariant 如此 使用分隔符将数字从关联文本中分离。True to use a separator to separate the numbers from the associated text. (使用仅当将 ReferenceType 参数设置为 wdRefTypeNumberedItem 和 ReferenceKind 参数设置为 wdNumberFullContext )。(Use only if the ReferenceType parameter is set to wdRefTypeNumberedItem and the ReferenceKind parameter is set to wdNumberFullContext.)
SeparatorStringSeparatorString 可选Optional VariantVariant 如果将 SeparateNumbers 参数设置为True,则指定要用作分隔符的字符串。Specifies the string to use as a separator if the SeparateNumbers parameter is set to True.


如果为 ReferenceKind 的值指定wdPageNumber ,则可能需要对文档重新分页以查看正确的交叉引用信息。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 _ 
With myRange 
 .InsertBefore "Page " 
 .Collapse Direction:=wdCollapseEnd 
 .InsertCrossReference ReferenceType:=wdRefTypeBookmark, _ 
 ReferenceKind:=wdPageNumber, ReferenceItem:=myBookmarks(1) 
End With

另请参阅See also

Range 对象Range Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.