共用方式為


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)

Syntax

'Declaration
Sub InsertCaption ( _
    ByRef Label As Object, _
    ByRef Title As Object, _
    ByRef TitleAutoText As Object, _
    ByRef Position As Object, _
    ByRef ExcludeLabel As Object _
)
void InsertCaption(
    ref Object Label,
    ref Object Title,
    ref Object TitleAutoText,
    ref Object Position,
    ref Object ExcludeLabel
)

Parameters

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

  • ExcludeLabel
    Type: System.Object%

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

Remarks

Optional Parameters

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

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

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace