Word

Print only pages with revisions

Ease of Use

Easy

Version tested with

2002 

Submitted by:

fumei

Description:

Code runs through the document printing only the pages with tracked revisions 

Discussion:

The code does not require that revisions be visible. It simply prints the pages that have them. If a pages has more than one revision the page is printed only once. It could be adjusted to print the same page for each revision on that page. The code displays a messages if there are no revisions, or if Track Changes is not enabled. 

Code:

instructions for use

			

Option Explicit Sub PrintRevisionPagesOnly() ' Print only pages with recorded revisions ' keyboard shortcut = Alt-P ' NOTE: if Track Changes is not enabled there ARE ' no recorded revisions. If Track Changes not enabled ' the code offers to enable it. Dim oRange As Word.Range Dim intPageCount As Integer Dim var Dim response If ActiveDocument.Range.Revisions.Count > 0 Then intPageCount = _ ActiveDocument.Range.Information(wdNumberOfPagesInDocument) Selection.HomeKey Unit:=wdStory On Error Resume Next For var = 1 To intPageCount Set oRange = _ ActiveDocument.Range _ (Start:=ActiveDocument.Bookmarks("\page").Start, _ End:=ActiveDocument.Bookmarks("\page").End - 1) If oRange.Revisions.Count > 0 Then Application.PrintOut FileName:="", Range:=wdPrintCurrentPage, _ Item:=wdPrintDocumentWithMarkup, Copies:=1, Pages:="" Selection.GoToNext wdGoToPage Else Selection.GoToNext wdGoToPage End If Set oRange = Nothing Next Else Select Case ActiveDocument.TrackRevisions Case False response = MsgBox("There are no recorded revisions in this " & _ "document. Track Changes is not enabled. Would " & _ "you like to turn Track Changes on?", vbYesNo) If response = vbYes Then ActiveDocument.TrackRevisions = True Case True MsgBox "There are no tracked revisions in this document." End Select End If End Sub

How to use:

  1. If you want this to be available in ALL documents insert the code into Normal.Dot, or a global template; otherwise - open the document you want the code in.
  2. Open the VBE (Alt-F11)
  3. Open the Project Explorer (Ctrl-R)
  4. Open the Project for the document (or template) you want to put the code in.
  5. Copy and paste the above code into a code module. ThisDocument is fine, or any other standard module
  6. Save and Close the VBE
 

Test the code:

  1. Unzip the attached file.
  2. The code will fire by a keyboard shortcut. Press Alt-P to run the code.
  3. First message appears stating no revisions, AND Track Changes is not enabled.
  4. Select No.
  5. Make some changes, and then run the code again (Alt-P)
  6. Same messages, as Track Changes still not enabled. Your changes are NOT recorded.
  7. Select Yes. This enables Track Changes.
  8. Make some changes and run the code again.
 

Sample File:

TrackChanges.zip 11.39KB 

Approved by mdmackillop


This entry has been viewed 227 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express