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


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


Type: System.Object

The caption label to be inserted. T:Microsoft.Office.Interop.Word.WdCaptionLabelID.

Type: System.Object

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

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).

Type: System.Object

Specifies whether the caption is inserted above or below the Bookmark control. T:Microsoft.Office.Interop.Word.WdCaptionPosition.

Type: System.Object

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

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()
    Microsoft.Office.Tools.Word.Bookmark 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);
Return to top