Word Count

B

Brennan Smith

Is there a way to get the total word count to include tables (in addition to
headers and footers)?
 
M

macropod

Hi Suzanne,

The {NUMWORDS} field doesn't count anything in text boxes, shapes, headers, footers, footnotes or endnotes and only counts hidden
text if the 'print hidden text' option is checked. Footnote & endnote references may or may not be counted, depending on where
they're located within the body of the document. The same applies to the {DOCPROPERTY "Words"} field.

To get a complete word count with a macro using ComputeStatistics(wdStatisticWords), you'd have to loop through all the story
ranges, tallying the count as you go.
 
J

Jay Freedman

A slight amendment: In Word 2007, the word count on the status bar and
the Word Count dialog will include text boxes and shapes (if that
option is checked in the Word Count dialog). The fields and
ComputeStatistics still behave as before.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

Hi Suzanne,

The {NUMWORDS} field doesn't count anything in text boxes, shapes, headers, footers, footnotes or endnotes and only counts hidden
text if the 'print hidden text' option is checked. Footnote & endnote references may or may not be counted, depending on where
they're located within the body of the document. The same applies to the {DOCPROPERTY "Words"} field.

To get a complete word count with a macro using ComputeStatistics(wdStatisticWords), you'd have to loop through all the story
ranges, tallying the count as you go.

--
Cheers
macropod
[Microsoft MVP - Word]


Suzanne S. Barnhill said:
AFAIK, it does.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
M

macropod

Thanks, Jay.

--
Cheers
macropod
[Microsoft MVP - Word]


Jay Freedman said:
A slight amendment: In Word 2007, the word count on the status bar and
the Word Count dialog will include text boxes and shapes (if that
option is checked in the Word Count dialog). The fields and
ComputeStatistics still behave as before.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

Hi Suzanne,

The {NUMWORDS} field doesn't count anything in text boxes, shapes, headers, footers, footnotes or endnotes and only counts hidden
text if the 'print hidden text' option is checked. Footnote & endnote references may or may not be counted, depending on where
they're located within the body of the document. The same applies to the {DOCPROPERTY "Words"} field.

To get a complete word count with a macro using ComputeStatistics(wdStatisticWords), you'd have to loop through all the story
ranges, tallying the count as you go.

--
Cheers
macropod
[Microsoft MVP - Word]


Suzanne S. Barnhill said:
AFAIK, it does.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

Is there a way to get the total word count to include tables (in addition to
headers and footers)?
 
G

Greg Maxey

Thanks, Jay.

--
Cheers
macropod
[Microsoft MVP - Word]



Jay Freedman said:
A slight amendment: In Word 2007, the word count on the status bar and
the Word Count dialog will include text boxes and shapes (if that
option is checked in the Word Count dialog). The fields and
ComputeStatistics still behave as before.
--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ:http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
On Sat, 31 Oct 2009 12:44:45 +1100, "macropod"
Hi Suzanne,
The {NUMWORDS} field doesn't count anything in text boxes, shapes, headers, footers, footnotes or endnotes and only counts hidden
text if the 'print hidden text' option is checked. Footnote & endnote references may or may not be counted, depending on where
they're located within the body of the document. The same applies to the {DOCPROPERTY "Words"} field.
To get a complete word count with a macro using ComputeStatistics(wdStatisticWords), you'd have to loop through all the story
ranges, tallying the count as you go.
--
Cheers
macropod
[Microsoft MVP - Word]
AFAIK, it does.
--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
Is there a way to get the total word count to include tables (in addition to
headers and footers)?- Hide quoted text -

- Show quoted text -

Jay, Macropod and Brennan,

I scratched together some code to provided a "best guess" total word
count. I say "best guess" because of a few unexplained and
confounding issues.

First, how are total words in headers and footers counted? If there
is one word in the header and the document is 100 pages long does that
count as one word (I would thing so) or 100? If That same word is in
a firstpage header, even page header, and primary page header looping
through the storyranges will count that word 3 times (as the code
below does). If the word should be counted as only 1 word it will be
counted as three. Now there are the sections. If that same 100 page
document as 100 sections each containing the same one word then it
will be counted 100 times instead of 1 time.

Second the footnote and endnote separator, continuation, and notice
stories all return 1 word even when empty. I skipped these and don't
really understand all of the ramificaitons.

Third. Shapes in headers or footers must be processed specifically.

In view of the first issue, it appears a hopelessly complex task to
create a true total Word count tools. For me anyway ;-)


Sub BestGuessWOrdCount()
Dim pRange As Word.Range
Dim oShp As Shape
Dim iLink As Long
Dim oCnt As Long
Dim TOC As TableOfContents
Dim TOF As TableOfFigures
Dim TOA As TableOfAuthorities
Dim pAlerts As String
pAlerts = Application.DisplayAlerts
Application.DisplayAlerts = wdAlertsNone
iLink = ActiveDocument.Sections(1).Headers(1).Range.StoryType
For Each pRange In ActiveDocument.StoryRanges
Select Case pRange.StoryType
Case 12, 13, 14, 15, 16, 17
'Skip footnote and endnote separation, continuation and notice
stories
Case Else
Do
oCnt = oCnt + pRange.ComputeStatistics(wdStatisticWords)
Select Case pRange.StoryType
Case 6, 7, 8, 9, 10, 11
If pRange.ShapeRange.Count > 0 Then
For Each oShp In pRange.ShapeRange
If oShp.TextFrame.HasText Then
oCnt = oCnt +
oShp.TextFrame.TextRange.ComputeStatistics(wdStatisticWords)
End If
Next oShp
End If
End Select
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
End Select
Next
Application.DisplayAlerts = pAlerts
MsgBox "The best guest word count in this document is " & oCnt & "
words."
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top