DocumentBase.ComputeStatistics(WdStatistic, Object) 方法

定义

基于文档的内容获取统计信息。

public int ComputeStatistics (Microsoft.Office.Interop.Word.WdStatistic statistic, ref object includeFootnotesAndEndnotes);

参数

statistic
WdStatistic

WdStatistic

includeFootnotesAndEndnotes
Object

如果为 true,则在计算统计信息时包括脚注和尾注。 默认值为 False。

返回

Int32

文档中由 Statistic 参数指定的该类型项的数目。

示例

下面的代码示例使用 ComputeStatistics 方法来显示文档中的单词数,不包括脚注和尾注。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。

private void DocumentComputeStatistics()
{
    object IncludeFootnotesAndEndnotes = false;

    int wordCount = this.ComputeStatistics(
        Word.WdStatistic.wdStatisticWords,
        ref IncludeFootnotesAndEndnotes);
    MessageBox.Show("There are " + wordCount.ToString() +
        " words in this document.");
}
Private Sub DocumentComputeStatistics()
    Dim wordCount As Integer = Me.ComputeStatistics( _
        Word.WdStatistic.wdStatisticWords, False)
    MessageBox.Show(("There are " + wordCount.ToString() + _
        " words in this document."))
End Sub

注解

可选参数

有关可选参数的信息,请参阅Office 解决方案中的可选参数

适用于