Compartilhar via


Bookmark.StoryLength Property

Definition

Gets the number of characters in the story that contains the Bookmark control.

public:
 property int StoryLength { int get(); };
public int StoryLength { get; }
member this.StoryLength : int
Public ReadOnly Property StoryLength As Integer

Property Value

The number of characters in the story that contains the Bookmark control.

Examples

The following code example adds a Bookmark control with text to the document and then displays the text of the bookmark in a message box if the story length is greater than 0.

This example is for a document-level customization.

private void BookmarkStoryLength()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();

    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "This is sample bookmark text.";
    
    if (bookmark1.StoryLength > 1)
    {
        MessageBox.Show(bookmark1.Text);
    }
}
Private Sub BookmarkStoryLength()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")

    Bookmark1.Text = "This is sample bookmark text."

    If bookmark1.StoryLength > 1 Then
        MessageBox.Show(Bookmark1.Text)
    End If

End Sub

Applies to