Skip to content

Instantly share code, notes, and snippets.

@dansherman
Created October 11, 2012 15:12
Show Gist options
  • Select an option

  • Save dansherman/3873118 to your computer and use it in GitHub Desktop.

Select an option

Save dansherman/3873118 to your computer and use it in GitHub Desktop.
Word VBA - Print redlines (only pages with revisions)
Sub PrintRedlines()
'see if we even need to run
If ActiveDocument.Revisions.Count = 0 Then
MsgBox "No revisions found."
End
End If
Dim strPages As String
Dim currpg As String
Dim prevpg As String
Dim currText As String
strPages = "p1"
prevpg = "p1"
Selection.HomeKey (wdStory)
For Each myRev In ActiveDocument.Range.Revisions
currpg = "p" & myRev.Range.Information(Word.WdInformation.wdActiveEndPageNumber)
currText = myRev.Range.Text
If Len(currText) < 10 And "Article" = Left(currText, 7) Then
myRev.Accept
GoTo nextmyrev
ElseIf myRev.FormatDescription <> "" And Left(currText, 1) <> "([0-9]{1,})" Then
myRev.Accept
GoTo nextmyrev
ElseIf myRev.Range.Information(Word.WdInformation.wdInHeaderFooter) _
And currpg = "p1" Then
myRev.Accept
GoTo nextmyrev
End If
If prevpg <> currpg _
And Not strPages Like "*" & currpg & "*" _
And Not currpg = "p1" Then 'add page to list, unless already there
strPages = strPages & "," & currpg
End If
nextmyrev:
prevpg = currpg
Next myRev
'Print
With Dialogs(wdDialogFilePrint)
.Range = wdPrintRangeOfPages
.Pages = strPages
.Show
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment