ComputeStatistics Method

Applies To

Document object, Range object.

Description

Syntax 1: Returns a statistic based on the contents of the specified document.

Syntax 2: Returns a statistic based on the contents of the specified range.

Syntax 1

expression.ComputeStatistics(Statistic, IncludeFootnotesAndEndnotes)

Syntax 2

expression.ComputeStatistics(Statistic)

expression Syntax 1: Required. An expression that returns a Document object.

Syntax 2: Required. An expression that returns a Range object.

Statistic Required Long. The statistic. Can be one of the following WdStatistic constants: wdStatisticCharacters, wdStatisticCharactersWithSpaces, wdStatisticLines, wdStatisticPages, wdStatisticParagraphs, or wdStatisticWords.

IncludeFootnotesAndEndnotes Optional Variant. True to include footnotes and endnotes when computing statistics. If this argument is omitted, the default value is False.

See Also

BuiltInDocumentProperties property.

Example

This example displays the number of words and characters in the first paragraph of Report.doc.

Set myRange = Documents("Report.doc").Paragraphs(1).Range
wordCount = myRange.ComputeStatistics(Statistic:=wdStatisticWords)
charCount = myRange.ComputeStatistics(Statistic:=wdStatisticCharacters)
MsgBox "The first paragraph contains " & wordCount _
    & " words and a total of " & charCount & " characters."
This example displays the number of words in the active document, including footnotes.

MsgBox ActiveDocument.ComputeStatistics(Statistic:=wdStatisticWords, _
    IncludeFootnotesAndEndnotes:=True) & " words"