Поделиться через


Bookmark.StoryLength Property

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

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

Syntax

'Declaration
ReadOnly Property StoryLength As Integer
int StoryLength { get; }

Property Value

Type: System.Int32
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 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
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);
    }
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace