ComputeStatistics Method
ComputeStatistics method as it applies to the Range object.
Returns a statistic based on the contents of the specified range. Long.
expression.ComputeStatistics(Statistic)
expression Required. An expression that returns one of the above objects.
Statistic Required WdStatistic.
WdStatistic can be one of these WdStatistic constants. |
wdStatisticCharacters |
wdStatisticCharactersWithSpaces |
wdStatisticFarEastCharacters |
wdStatisticLines |
wdStatisticPages |
wdStatisticParagraphs |
wdStatisticWords |
ComputeStatistics method as it applies to the Document object.
Returns a statistic based on the contents of the specified document. Long.
expression.ComputeStatistics(Statistic, IncludeFootnotesAndEndnotes)
expression Required. An expression that returns one of the above objects.
Statistic Required WdStatistic.
WdStatistic can be one of these WdStatistic constants. |
wdStatisticCharacters |
wdStatisticCharactersWithSpaces |
wdStatisticFarEastCharacters |
wdStatisticLines |
wdStatisticPages |
wdStatisticParagraphs |
wdStatisticWords |
IncludeFootnotesAndEndnotes Optional Variant. True to include footnotes and endnotes when computing statistics. If this argument is omitted, the default value is False.
Remarks
Some of the constants listed above may not be available to you, depending on the language support (U.S. English, for example) that you’ve selected or installed.
Example
As it applies to the Range object.
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."
As it applies to the Document object.
This example displays the number of words in the active document, including footnotes.
MsgBox _
ActiveDocument.ComputeStatistics(Statistic:=wdStatisticWords, _
IncludeFootnotesAndEndnotes:=True) & " words"