InsertCaption Method

Inserts a caption immediately preceding or following the specified range or selection.

expression**.InsertCaption(Label**, Title, TitleAutoText, Position, ExcludeLabel)

expression Required. An expression that returns a Range or Selection object.

WdCaptionLabelID

Can be a string or one of the following WdCaptionLabelID constants.

wdCaptionEquation

wdCaptionFigure

wdCaptionTable

If the label hasn't yet been defined, an error occurs. Use the Add method with the CaptionLabels object to define new caption labels.

Title    Optional Variant. The string to be inserted immediately following the label in the caption (ignored if TitleAutoText is specified).

TitleAutoText    Optional Variant. The AutoText entry whose contents you want to insert immediately following the label in the caption (overrides any text specified by Title).

WdCaptionPosition

Can be either of the following WdCaptionPosition constants.

wdCaptionPositionAbove

wdCaptionPositionBelow.

ExcludeLabel    Optional Variant. True does not include the text label, as defined in the Label parameter. False includes the specified label.

Example

This example inserts a caption below the first table in the active document.

ActiveDocument.Tables(1).Range.InsertCaption _
    Label:=wdCaptionTable, _
    Position:=wdCaptionPositionBelow

This example inserts a Figure caption at the insertion point.

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

Applies to | Range Object | Selection Object

See Also | Add Method | InsertCrossReference Method