Word Count

K

Kathryn

I am writing a document for university with a strict word
limit. This limit includes the main text only, and not
text related to pictures, headings, references and certain
other parts of the document. I would like to know what is
and is not included in the word count (for example are
headers and footers, or text in text boxes included), and
is there any way I can get it to only count words in text
of my choice (blocks of text I need to count are
interrupted by other text that I don't need to count) or
am I going to have to do it by hand?
 
L

Larry

I can point you roughly in a direction of something that will work, but
someone else will have to show you the rest of the way. Let's say that
all the text you want to count in the document in in Normal style. You
don't want to count words in Heading style for example. This macro will
go through the document, selecting each paragraph in Normal style and
counting the selection, then looking for the next paragraph in Normal
style, and so on. However, if you have a bunch of styles that you need
to count, you would need to have similar code for each style.

If there's only one style that you don't want to count, the approach
might be to loop through the paragraphs in that style, (say, Heading 2)
and then subtract that number from the total wordcount for the document.

But the crucial step, which I don't know how to do, is to create a
series of results so that all the wordcounts for each of counted
paragraphs can be made separately and then added together at the end of
the macro.

Also, this won't work with Word 97, because the ComputeStatistics does
not return a correct result on a range in Word 97, though it does work
for the whole document.

Application.ScreenUpdating = False
With Selection.Find
.ClearFormatting
.Style = ActiveDocument.Styles("Normal")
.Text = ""
.Forward = True
.Wrap = wdFindContinue

Do While .Execute
X = Selection.Range.ComputeStatistics(wdStatisticWords)
Loop
End With
 

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