Counting the number of pages that contain highlighting

C

ChristyW

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.
 
G

Greg Maxey

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
 
C

ChristyW

Thanks, Greg!
That works great for what we need. As I said, it was kind of a strange
request. The number of pages doesn't really reflect the information our
client should be asking for -- some highlighted pages have several
revisions, and some have only one. But this gives us what they have asked
for without someone having to manually count the pages, so thank you!
Christy
 

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