Expand Minimize

Bookmark.InsertCaption Method

Inserts a caption immediately preceding or following the Bookmark control.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

void InsertCaption(
	ref Object Label,
	ref Object Title,
	ref Object TitleAutoText,
	ref Object Position,
	ref Object ExcludeLabel
)

Parameters

Label
Type: System.Object

The caption label to be inserted. WdCaptionLabelID.

Title
Type: System.Object

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

TitleAutoText
Type: System.Object

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

Position
Type: System.Object

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

ExcludeLabel
Type: System.Object

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

Optional Parameters

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

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);
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft