Bookmark.InsertCaption(Object, Object, Object, Object, Object) Method

Definition

Inserts a caption immediately preceding or following the Bookmark control.

public void InsertCaption (ref object Label, ref object Title, ref object TitleAutoText, ref object Position, ref object ExcludeLabel);
abstract member InsertCaption : obj * obj * obj * obj * obj -> unit
Public Sub InsertCaption (ByRef Label As Object, Optional ByRef Title As Object, Optional ByRef TitleAutoText As Object, Optional ByRef Position As Object, Optional ByRef ExcludeLabel As Object)

Parameters

Label
Object

The caption label to be inserted. WdCaptionLabelID.

Title
Object

The text to be inserted immediately following the label in the caption (ignored if TitleAutoText is specified).

TitleAutoText
Object

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

Position
Object

Specifies whether the caption is inserted above or below the Bookmark control. WdCaptionPosition.

ExcludeLabel
Object

true to not include the text label, as defined in the Label parameter. false to include the specified label.

Examples

The following code example adds a Bookmark control with text to the document and then inserts a caption into the bookmark.

This example is for a document-level customization.

private void BookmarkInsertCaption()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "First bookmark";

    object Label = Word.WdCaptionLabelID.wdCaptionFigure;
    object Position = Word.WdCaptionPosition.wdCaptionPositionAbove;
    object ExcludeLabel = false;

    bookmark1.InsertCaption(ref Label, ref missing, ref missing,
        ref Position, ref ExcludeLabel);
}
Private Sub BookmarkInsertCaption()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")
    Bookmark1.Text = "First bookmark"

    Bookmark1.InsertCaption(Label:=Word.WdCaptionLabelID.wdCaptionFigure, _
        Position:=Word.WdCaptionPosition.wdCaptionPositionAbove, _
        ExcludeLabel:=False)

End Sub

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to