C
Charlie Mac
The correct word count (all words in document) via the Tools, Word
Count menu is 600. I need an accurate word count in my macro and
none of these methods work. What am I doing wrong? Please help.
' 544 words reported in document code:
Set mystat = ActiveDocument.ReadabilityStatistics
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToFirst
MyWordCnt = mystat(1).Value ' word count
MsgBox MyWordCnt
' 674 words reported in document code:
Set MyRange = Selection.Range
MyRange.WholeStory
MyWordCnt = MyRange.Words.Count
MsgBox MyWordCnt
' This code usually counts an extra 2 to 6 words in sentences
For Each aPara In MyRange.Paragraphs
For Each aSent In aPara.Range.Sentences
WordCnt = -1 ' Word counts the period as a word
For Each aWord In aSent.Words
WordCnt = WordCnt + 1 ' word counter in sentence
Next
msgbox WordCnt
Next
Next
Count menu is 600. I need an accurate word count in my macro and
none of these methods work. What am I doing wrong? Please help.
' 544 words reported in document code:
Set mystat = ActiveDocument.ReadabilityStatistics
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToFirst
MyWordCnt = mystat(1).Value ' word count
MsgBox MyWordCnt
' 674 words reported in document code:
Set MyRange = Selection.Range
MyRange.WholeStory
MyWordCnt = MyRange.Words.Count
MsgBox MyWordCnt
' This code usually counts an extra 2 to 6 words in sentences
For Each aPara In MyRange.Paragraphs
For Each aSent In aPara.Range.Sentences
WordCnt = -1 ' Word counts the period as a word
For Each aWord In aSent.Words
WordCnt = WordCnt + 1 ' word counter in sentence
Next
msgbox WordCnt
Next
Next