Bert,
The following will come closer to selecting the actual number of words that
are entered into the input box.
Dim wordnum As Long
Dim i As Long
Dim wordrange As Range
Dim source As Document
Dim realwords As Long
Set source = ActiveDocument
wordnum = InputBox("Enter the number of the word to which you want to go", _
"Go to Word Number", 1)
Set wordrange = source.Range
wordrange.End = source.Words(wordnum).End
wordrange.Select
Set Temp = Dialogs(wdDialogToolsWordCount)
Temp.Execute
realwords = Temp.Words
Set Temp = Nothing
i = 1
Application.ScreenUpdating = False
Do While realwords wordnum
Set wordrange = source.Range
wordrange.End = source.Words(wordnum + i).End
wordrange.Select
Set Temp = Dialogs(wdDialogToolsWordCount)
Temp.Execute
realwords = Temp.Words
i = i + 1
Set Temp = Nothing
Loop
Application.ScreenRefresh
Application.ScreenUpdating = True
Depending upon the number of "bogus" words it may take a little while to
run.
Note however that one - two - three will still count as 5 words. On the
other hand one-two-three will count as 1 word.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"Bert Coules" wrote in message
...
Doug Robbins wrote:
...I guess all you can do is add some allowance for punctuation on top of
the 4000.
Doug, I've been playing around with the whole word count utility. I
hadn't previously realised that it counts any item which is preceded and
succeeded by spaces as a word: so, for example, "one - two - three" is
reported as five words, which it patently is not.
Short of a macro which first counts everything which Word regards as words
then tallies up all the included non-words and subtracts them from the
count, do you know of any way to obtain a genuine word-count?
Bert
www.bertcoules.co.uk