InsertCaption 方法 (Word)Selection.InsertCaption method (Word)

紧靠在指定的所选内容之前或之后插入题注。Inserts a caption immediately preceding or following the specified selection.

语法Syntax

expressionexpression. InsertCaption( _Label_ , _Title_ , _TitleAutoText_ , _Position_ , _ExcludeLabel_ )

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

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
LabelLabel 必需Required VariantVariant 要插入的题注标签。The caption label to be inserted. 可以是一个字符串, 也可以是WdCaptionLabelID常量之一。Can be a String or one of the WdCaptionLabelID constants. 如果未定义标签,则会导致出错。If the label has not yet been defined, an error occurs. 使用 CaptionLabels 对象的 Add 方法来定义新的题注标签。Use the Add method with the CaptionLabels object to define new caption labels.
TitleTitle 可选Optional VariantVariant 要紧接在题注标签之后插入的字符串(如果已指定 TitleAutoText,则忽略该参数)。The string to be inserted immediately following the label in the caption (ignored if TitleAutoText is specified).
TitleAutoTextTitleAutoText 可选Optional VariantVariant 要紧接在题注标签之后插入其内容的"自动图文集"词条(将覆盖由 Title 指定的任何文本)。The AutoText entry whose contents you want to insert immediately following the label in the caption (overrides any text specified by Title).
PositionPosition 可选Optional VariantVariant 指定是否高于或低于所选内容插入题注。Specifies whether the caption will be inserted above or below the selection. 可以是WdCaptionPosition常量之一。Can be one of the WdCaptionPosition constants.
ExcludeLabelExcludeLabel 可选Optional VariantVariant 没有文本标签,在标签参数中定义。True does not include the text label, as defined in the Label parameter. 错误 包含指定的标签。False includes the specified label.

示例Example

以下示例在插入点插入图表题注。This example inserts a Figure caption at the insertion point.

Selection.Collapse Direction:=wdCollapseStart 
Selection.InsertCaption Label:="Figure", _ 
 Title:=": Sales Results", Position:=wdCaptionPositionBelow

另请参阅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.