word counting

G

Guest

I need to have a word count on each page in my document (over 500 pages).
We can only have so many words and lines on each page. I know how to set up
the line count but not the word count. Thank you
 
J

Jezebel

Step 1: write a macro that selects each page in turn, calculates the word
count, and saves the value as a document variable with a name like Vnnn,
where nnn is the page number.

Step 2: add a docvariable field to the header or footer where you want to
display the value --

{ DocVariable { Page \# "V000" } }
 
G

Guest

Thank you but I have no idea how to do macros. I forgot to tell you that
I'm just starting.
 
D

Doug Robbins - Word MVP

The following macro will create the document variables

Sub InsertNumberofWordsonPage()
Dim i As Long
Dim Source As Document
Dim varname As String
Set Source = ActiveDocument
Selection.HomeKey Unit:=wdStory

Pages = Source.BuiltInDocumentProperties(wdPropertyPages)
i = 0
While i < Pages
i = i + 1
varname = "V" & Format(i, "000")
With Source
.Variables(varname).Value =
..Bookmarks("\page").Range.ComputeStatistics(wdStatisticWords)
.Bookmarks("\Page").Range.Cut
End With
Wend
Source.Undo (i)
End Sub

To create the docvariable field { DocVariable { Page \# "V000" } }that
Jezebel gave you, you must use Ctrl+F9 for each pair of field delimiters.

Make sure you save the document BEFORE running the above macro just in case
something goes wrong as it deletes each page of the document and then undoes
the deletion. In testing here though, everything worked fine.
--
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
 
G

Guest

Thank you for you for trying to help me, but I can't get it to work. It keep
stopping on ..Bookmarks("\page").Range.ComputeStatistics(wdStatisticWords).
I don't know what I have done or haven't done. this stuff really makes a
person feel stupid.
 
J

Jay Freedman

The newsgroup introduced an unwanted line break, and I think Doug got an
extra dot in that line by mistake. These two lines should be combined into
one line, with only one dot before "Bookmarks":

.Variables(varname).Value =
..Bookmarks("\page").Range.ComputeStatistics(wdStatisticWords)

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

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