Results 1 to 12 of 12
  1. #1
    Lounger
    Join Date
    Aug 2002
    Location
    Oklahoma City, Oklahoma, USA
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print pages with changes (Word 2000)

    Has anyone ever seen a macro to print only pages that have tracked changes on them?

  2. #2
    4 Star Lounger
    Join Date
    Nov 2002
    Location
    London, Gtr London, England
    Posts
    496
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Print pages with changes (Word 2000)

    Hi,

    I haven't done it but I think you need to do something like this
    For the document
    use Track Changes, Accept or Reject, Find then exit this - the cahnge will be highlighted thus placing on a required page
    Store the page number in an array
    do this until the end of the document which will give you all the required pages in the array
    print the document using the pages stored in the array

    I haven't generated the code but I think it should be relatively simple

    liz

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Print pages with changes (Word 2000)

    I've never seen one before, but I just wrote one. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    <pre>Option Explicit
    ' User-defined type to mix data types in a single, 1-dimensional array
    Type PageInfo 'index by physical page number
    piLogical As String 'p1s2 or physical number
    piStart As Long 'Start of range relative to document
    piHasChanges As Boolean 'As the names says...
    End Type

    Sub TestSub()
    'Demo using function to return print range of pages with tracked changes
    With Dialogs(wdDialogFilePrint)
    .Range = wdPrintRangeOfPages
    ' Note: not sure what the maximum legal size is for this string...
    .Pages = TrackedChangesPrintRange(ActiveDocument)
    .Show ' displays and executes
    End With
    End Sub

    Function TrackedChangesPrintRange(docTarget As Document) As String
    ' Jefferson Scher 9 Dec 2002
    ' Iterate over the pages in the document checking for tracked changes, then
    ' return a string for the print dialog/method; this might fail to detect
    ' changes in headers and footers after section 1 (not sure...)

    ' Check for tracked changes in the document
    If docTarget.Revisions.Count = 0 Then
    TrackedChangesPrintRange = vbNullString
    Exit Function
    End If

    ' Declare an array to contain page information and an index var; temporary
    ' range used in multi-section documents
    Dim pgInfo() As PageInfo, i As Integer, rngTemp As Range
    ' Size the array and capture page info
    ReDim pgInfo(1 To docTarget.ComputeStatistics(wdStatisticPages))
    If docTarget.Sections.Count > 1 Then
    Set rngTemp = docTarget.Range(0, 0)
    End If
    For i = 1 To UBound(pgInfo)
    pgInfo(i).piStart = docTarget.Range.GoTo(what:=wdGoToPage, _
    which:=wdGoToAbsolute, Count:=i).Start
    If rngTemp Is Nothing Then
    pgInfo(i).piLogical = CStr(i)
    Else 'use logical page number and section at start of physical page
    Set rngTemp = docTarget.Range(Start:=pgInfo(i).piStart, End:=pgInfo(i).piStart)
    pgInfo(i).piLogical = _
    "p" & rngTemp.Information(wdActiveEndAdjustedPageNumber) & _
    "s" & rngTemp.Information(wdActiveEndSectionNumber)
    ' leave rngTemp set for next iteration through loop
    End If
    Next

    ' Check for tracked changes on the pages and record in the array
    For i = 1 To UBound(pgInfo)
    On Error Resume Next
    Set rngTemp = docTarget.Range(pgInfo(i).piStart, pgInfo(i + 1).piStart - 1)
    If Err.Number = 9 Then 'Last array item
    Set rngTemp = docTarget.Range(pgInfo(i).piStart, docTarget.Range.End)
    Err.Clear
    ElseIf Err.Number <> 0 Then
    MsgBox Err.Number & vbCrLf & Err.Description
    Stop
    End If
    On Error GoTo 0
    If rngTemp.Revisions.Count > 0 Then
    pgInfo(i).piHasChanges = True
    End If
    Next

    'Build a return string
    Dim intRangePages As Integer
    For i = 1 To UBound(pgInfo)
    If pgInfo(i).piHasChanges Then
    Select Case intRangePages
    Case 0
    TrackedChangesPrintRange = TrackedChangesPrintRange & _
    "," & pgInfo(i).piLogical
    intRangePages = 1
    Case Else 'increment number-of-pages-in-a-row count
    intRangePages = intRangePages + 1
    End Select
    Else
    Select Case intRangePages
    Case 0
    'do nothing
    Case 1 'reset number-of-pages-in-a-row count
    intRangePages = 0
    Case Else
    TrackedChangesPrintRange = TrackedChangesPrintRange & _
    "-" & pgInfo(i - 1).piLogical
    intRangePages = 0
    End Select
    End If
    Next
    ' Add closing page number if needed
    If intRangePages > 1 Then
    TrackedChangesPrintRange = TrackedChangesPrintRange & _
    "-" & pgInfo(UBound(pgInfo)).piLogical
    End If
    ' Trim leading comma from the return string
    TrackedChangesPrintRange = Mid(TrackedChangesPrintRange, 2)

    ' Clean up objects
    If Not rngTemp Is Nothing Then Set rngTemp = Nothing
    Set docTarget = Nothing
    End Function</pre>

    Note: I only tested on one document; this should be tested more before being released to the masses.

    My first idea of checking every revision in the ActiveDocument.Revisions collection probably would be even less efficient. Hopefully this code will come in handy in other situations where one wants to interrogate a range corresponding to a physical document page.

  4. The Following User Says Thank You to jscher2000 For This Useful Post:

    MiKe_W (2011-01-20)

  5. #4
    Lounger
    Join Date
    Aug 2002
    Location
    Oklahoma City, Oklahoma, USA
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print pages with changes (Word 2000)

    Many thanks, you are a real wizard. I have tested it some and the macro seems to work. I have put this in my normal.dot and plan to use it a lot.

    I had to put "private" before the type statement. One improvement I might try to add is to first make sure Tools Track Changes dialog has the print changes box checked. It is a hike to my color printer and it is slow, so its pretty disappointing to get the right pages printed but without the red-lining because I forgot that!

  6. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Print pages with changes (Word 2000)

    Good idea!

    If Not docTarget.PrintRevisions Then docTarget.PrintRevisions = True

    Unlike some toggle settings, I wouldn't save the original state and change it back. This property should ALWAYS be TRUE (to avoid embarrassment).

  7. #6
    Star Lounger
    Join Date
    Jan 2006
    Location
    McLean, Virginia, USA
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print pages with changes (Word 2000)

    Does this work for WORD '03??

  8. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print pages with changes (Word 2000)

    I see no reason it shouldn't - have you tried it?

  9. #8
    Star Lounger
    Join Date
    Dec 2002
    Location
    San Francisco, California, USA
    Posts
    54
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Print pages with changes (Word 2000)

    Where in your original program are you including this code?

    If Not docTarget.PrintRevisions Then docTarget.PrintRevisions = True

    In the function near the end? Does it matter?
    Thanks,
    Larry

  10. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Print pages with changes (Word 2000)

    Hi Larry, I don't remember this thread very well. It has only been five years, but still...

    Well, that code needs to be executed before the .Show method is called to print the document. I think it makes sense to place it after the first End If in the function. That way, it is executed only if there are revisions. (I wonder whether it might change the pagination? Hmmm...)

  11. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print pages with changes (Word 2000)

    No, insert the line below the End If.

  12. #11
    Star Lounger
    Join Date
    Dec 2002
    Location
    San Francisco, California, USA
    Posts
    54
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Print pages with changes (Word 2000)

    <P ID="edit" class=small>(Edited by lmo on 05-Dec-07 19:24. )</P>Jefferson,

    Thanks for your reply. Sorry to take you back 5 years. I was having problems with DeltaView (charts moving in the blackline output) and ChangePro (creating .pdfs one page at a time of changed pages) and hoped that native Word's Track Changes might solve the problem. Your macro was the piece missing from Track Changes.

    Now, back to your suggestion. So, if I understand you correctly, you suggest the following change to your function:

    If docTarget.Revisions.Count = 0 Then
    TrackedChangesPrintRange = vbNullString
    Exit Function
    End If
    ***code addition
    If Not docTarget.PrintRevisions Then docTarget.PrintRevisions = True
    '***end code addition

    Thanks again for your reply.

    Larry

  13. The Following User Says Thank You to lmo For This Useful Post:

    MiKe_W (2011-01-20)

  14. #12
    New Lounger
    Join Date
    Oct 2002
    Location
    Salford, Lancashire, England
    Posts
    5
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Post

    Can I just say thanks for a very useful thread (still, even after 7 years now ) .... have been wanting to do this for a while now, only just thought of searching on here...doh!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •