Expand Minimize

Bookmark.ComputeStatistics Method

Gets a statistic based on the contents of the Bookmark control.

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

int ComputeStatistics(
	WdStatistic Statistic
)

Return Value

Type: System.Int32
A statistic based on the contents of the Bookmark control.

The following code example adds a Bookmark control with text and then displays the total number of characters in the bookmark using the ComputeStatistics method.

This example is for a document-level customization.

private void BookmarkComputeStatistics()
{
    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.";
    int totalCharacters = bookmark1.ComputeStatistics(Word
        .WdStatistic.wdStatisticCharacters);
    MessageBox.Show("The bookmark contains " + 
        totalCharacters.ToString() + " characters.");
}

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