InsertCrossReference 方法 (Word)Selection.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).

语法Syntax

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

expression:必需。expression Required. 表示 Selection 对象的变量。A variable that represents a Selection object.

参数Parameters

名称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 box 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 将交叉引用作为超链接插入。True to insert the cross-reference as a hyperlink.
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.

备注Remarks

如果为 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.

示例Example

以下示例插入一个句子,其中包含两个交叉引用:一个引用标题文字,另一个引用标题文字出现的页。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

另请参阅See also

Selection 对象Selection 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.