Udostępnij za pośrednictwem


DocumentBase.ComputeStatistics Method

Gets a statistic based on the contents of the document.

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

Syntax

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

Parameters

  • includeFootnotesAndEndnotes
    Type: System.Object%
    true to include footnotes and endnotes when computing statistics. The default value is false.

Return Value

Type: System.Int32
The number of items of the type specified by the Statistic parameter that are in the document.

Remarks

Optional Parameters

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

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 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 Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace