ComputeStatistics Method Home
Word 2003 VBA Language Reference
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.

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.

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"
				




© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View