Doug Robbins - Word MVP said:
The quickest way would be to use Edit>Replace to replace "planet" with
"planet" At the very least it saves the time of writing the code to do it
in some other way.
If you need the result in a macro, maybe check out
http://word.mvps.org/FAQs/MacrosVBA/GetNoOfReplacements.htm
In some cases, it might be quicker to get the text into a string, and count
the number of occurrences there:
Dim sText As String
sText = ActiveDocument.Content.Text
Dim sWord As String
sWord = "planet"
Dim iNum As Long
iNum = UBound(Split(sText, sWord))
' or make it case-insensitive:
iNum = UBound(Split(UCase(sText), UCase(sWord)))
Debug.Print sWord & " appears " & iNum & " times."
Getting the text into the string takes some time, so that approach likely
does not pay off if you just need to count the number of times *one* word
appears.
But if you need to do that for many words though, or need to fetch lots of
other info that you can get directly from the string, it's often quicker.
Regards,
Klaus