DocumentBase.ComputeStatistics 方法

依據文件的內容取得統計資料。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

'宣告
Public Function ComputeStatistics ( _
    statistic As WdStatistic, _
    ByRef includeFootnotesAndEndnotes As Object _
) As Integer
public int ComputeStatistics(
    WdStatistic statistic,
    ref Object includeFootnotesAndEndnotes
)

參數

  • includeFootnotesAndEndnotes
    型別:System.Object%
    true 表示計算統計資料時併入註腳和章節附註。預設值為 false。

傳回值

型別:System.Int32
在文件中,由 Statistic 參數所指定之型別的項目數。

備註

選擇性參數

如需選擇性參數的詳細資訊,請參閱Office 方案中的選擇性參數

範例

下列程式碼範例會使用 ComputeStatistics 方法顯示文件中的字數,但是不包括註腳和章節附註。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

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

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間