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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|