Bookmark.ComputeStatistics 方法 (2007 system)

更新:2007 年 11 月

获取基于 Bookmark 控件的内容的统计信息。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word.v9.0(在 Microsoft.Office.Tools.Word.v9.0.dll 中)

语法

声明
Public Function ComputeStatistics ( _
    Statistic As WdStatistic _
) As Integer
用法
Dim instance As Bookmark
Dim Statistic As WdStatistic
Dim returnValue As Integer

returnValue = instance.ComputeStatistics(Statistic)
public int ComputeStatistics(
    WdStatistic Statistic
)

参数

返回值

类型:System.Int32

基于 Bookmark 控件的内容的统计信息。

示例

下面的代码示例添加一个带有文本的 Bookmark 控件,然后使用 ComputeStatistics 方法显示该书签中的字符总数。

此示例针对的是文档级自定义项。

Private Sub BookmarkComputeStatistics()

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

    Dim totalCharacters As Integer = Bookmark1.ComputeStatistics( _
        Word.WdStatistic.wdStatisticCharacters)
    MessageBox.Show("The bookmark contains " & _
        totalCharacters.ToString() & " characters.")

End Sub
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.");
}

权限

另请参见

参考

Bookmark 类

Bookmark 成员

Microsoft.Office.Tools.Word 命名空间