View Single Post
  #2   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Greg Maxey Greg Maxey is offline
external usenet poster
 
Posts: 171
Default Counting the number of pages that contain highlighting

This is problematic first of all because a Word page isn't a page until
it is displayed on a screen or printed on paper. That done, page shown
on my screen or from my printer may very well be different that that
shown on yours.

For an excellent explanation of all of this see:

http://daiya.mvps.org/wordpages.htm

That said, a crude method, and it would only account for highlighting
in the main text story range (e.g., headers, footers, footnotes, etc.
are ignored) would look something like this:

Sub ScratchMacro()
Dim oRng1 As Word.Range
Dim oRng2 As Word.Range
Dim oCount As Long
ActiveDocument.Bookmarks("\startofdoc").Select
Set oRng1 = Selection.Range
Do
Set oRng1 = ActiveDocument.Bookmarks("\Page").Range
Set oRng2 = oRng1.Duplicate
With oRng2.Find
.Highlight = True
.Execute
If .Found = True Then
oCount = oCount + 1
End If
oRng1.Collapse wdCollapseEnd
oRng1.Move wdCharacter, 1
oRng1.Select
End With
Loop Until oRng1.End = ActiveDocument.Range.End - 1
MsgBox oCount
End Sub


ChristyW wrote:
I have a kind of strange request.



We have a series of relatively long documents that have gone through several
reviews over the period of a year. Each time we have made the client's
changes from a review, we have saved a copy of the documents with the
changed paragraphs highlighted.



Now the client is asking us how many pages of these documents we have
changed in each of the reviews. Is there a way to automate a search for
this? I know we can do a "Find" for "Format: Highlight" but is there a way
to add up all the instances it finds and tally up the number of pages on
which it found a highlighted area?



Thanks.