A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

word count in word 2007



 
 
Thread Tools Display Modes
  #1  
Old February 20th, 2009, 11:11 PM posted to microsoft.public.word.docmanagement
Scott
external usenet poster
 
Posts: 1,119
Default word count in word 2007

im trying to automatically add a word count to the bottom of each page in a
document created in word 2007 can anyone help me please
  #2  
Old February 20th, 2009, 11:29 PM posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill
external usenet poster
 
Posts: 31,786
Default word count in word 2007

You can do it using a NumWords field in the footer, but note that it won't
be a word count for the page but for the whole document. You can select text
(the whole page, for example) and get a word count for the selection, but
there's no field for that, nor any switch to tell NumWords to count just a
selection.

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

"scott" wrote in message
...
im trying to automatically add a word count to the bottom of each page in
a
document created in word 2007 can anyone help me please


  #3  
Old February 21st, 2009, 12:09 AM posted to microsoft.public.word.docmanagement
Greg Maxey[_2_]
external usenet poster
 
Posts: 649
Default word count in word 2007

Scott,

No small challenge and you may not be satisfied with the result. Part of
the problem is if the page is already "full" of words then adding more
(i.e., the word count) would push existing words to the next page. That
part can be overcome.

The problem that will likely lead to unsatisfactory results is the type of
things that Word considers a words.

Try running the following macro. This computes the number of words in a
built-in bookmark "\Page" range for each page and displays the results in a
textbox outside the traditional margins.

Sub ComputeWordsPerPage()
Dim oRng As Word.Range
Dim oShape As Shape
Dim oCount As Long
Set oRng = ActiveDocument.Content
oRng.Collapse wdCollapseStart
oRng.Select
Do
Set oRng = Selection.Bookmarks("\Page").Range
oCount = oRng.ComputeStatistics(wdStatisticWords)
oRng.Collapse wdCollapseEnd
oRng.Move wdCharacter, -1
Set oShape =
ActiveDocument.Shapes.AddTextbox(msoTextOrientatio nHorizontal, 0, 0, 125,
20)
With oShape
.TextFrame.TextRange.Text = oCount & " words this page."
.Left = InchesToPoints(0)
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.Top = InchesToPoints(9)
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
End With
oRng.Move wdCharacter, 1
oRng.Select
Loop Until oRng.End = ActiveDocument.Range.End - 1
End Sub


scott wrote:
im trying to automatically add a word count to the bottom of each
page in a document created in word 2007 can anyone help me please


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org



  #4  
Old February 21st, 2009, 04:31 PM posted to microsoft.public.word.docmanagement
Greg Maxey[_2_]
external usenet poster
 
Posts: 649
Default word count in word 2007

Scott,

I have added a bit of refinement to the macro so if the word count changes
it is easier to update the displayed count:

Sub ComputeWordsPerPage()
Dim oRng As Word.Range
Dim i As Long
Dim oShape As Shape
Dim oCount As Long
Set oRng = ActiveDocument.Content
oRng.Collapse wdCollapseStart
oRng.Select
i = 1
Do
On Error Resume Next
Set oShape = ActiveDocument.Shapes("Page " & i & " word count")
oShape.Delete
On Error GoTo 0
Set oRng = Selection.Bookmarks("\Page").Range
oCount = oRng.ComputeStatistics(wdStatisticWords)
oRng.Collapse wdCollapseEnd
oRng.Move wdCharacter, -1
Set oShape =
ActiveDocument.Shapes.AddTextbox(msoTextOrientatio nHorizontal, 0, 0, 160,
24)
With oShape
.Name = "Page " & i & " word count"
.TextFrame.TextRange.Text = "This page contains " & oCount & " words."
.Fill.ForeColor = wdColorLightYellow
.Left = InchesToPoints(0)
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.Top = InchesToPoints(9.25)
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
End With
oRng.Move wdCharacter, 1
oRng.Select
i = i + 1
Loop Until oRng.End = ActiveDocument.Range.End - 1
End Sub

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org


"scott" wrote in message
...
im trying to automatically add a word count to the bottom of each page in
a
document created in word 2007 can anyone help me please



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.