共用方式為


DocumentBase.ComputeStatistics(WdStatistic, Object) Method

Definition

Gets a statistic based on the contents of the document.

public int ComputeStatistics (Microsoft.Office.Interop.Word.WdStatistic statistic, ref object includeFootnotesAndEndnotes);
member this.ComputeStatistics : Microsoft.Office.Interop.Word.WdStatistic * obj -> int
Public Function ComputeStatistics (statistic As WdStatistic, Optional ByRef includeFootnotesAndEndnotes As Object) As Integer

Parameters

statistic
WdStatistic

A WdStatistic.

includeFootnotesAndEndnotes
Object

true to include footnotes and endnotes when computing statistics. The default value is false.

Returns

The number of items of the type specified by the Statistic parameter that are in the document.

Examples

The following code example uses the ComputeStatistics method to display the number of words in the document, excluding footnotes and endnotes. To use this example, run it from the ThisDocument class in a document-level project.

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

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to