T
Tim
In Word 2000, I have a subroutine to compare two documents
and after comparing them, cycle through the collection and
print any page with revisions. The trouble is it seems to
get hung up on certain revisions when stepping through the
collection and Word stops responding. Debug.Print
statements show it gets hung up when the code tries to get
the page number of a particular revision. The bare bones
code, stripped down to its essence, is:
Public Sub CompAndPrint(strDoc1 As String, _
strDoc2 As String)
Dim objWordApp As Word.Application
Dim objRev As Word.Revision
Dim intLastPagePrinted As Integer
Dim intCurrentRevPage As Integer
Dim strPageList As String
Set objWordApp = New Word.Application
With objWordApp
.DisplayAlerts = wdAlertsNone
.Documents.Open FileName:=strDoc1, _
AddToRecentFiles:=False '1st document
.ActiveDocument.Compare Name:=strDoc2 'compare with 2nd
intLastPagePrinted = 0
For Each objRev In .ActiveDocument.Revisions
intCurrentRevPage = _
objRev.Range.Information(wdActiveEndPageNumber)
'check if added to page list yet
If intLastPagePrinted <> intCurrentRevPage Then
intLastPagePrinted = intCurrentRevPage
strPageList = strPageList & _
Format$(intLastPagePrinted) & ","
End If
Next objRev
strPageList = Left$(strPageList, _
-1 + Len(strPageList)) 'remove last ,
'now print
.PrintOut FileName:="", Range:=wdPrintRangeOfPages, _
Item:=wdPrintDocumentContent, Copies:=1, _
Pages:=strPageList, PageType:=wdPrintAllPages, _
Collate:=False, Background:=False, _
PrintToFile:=False, _
PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
'close, don't save
.ActiveDocument.Close wdDoNotSaveChanges
End With
objWordApp.Quit
Set objWordApp = Nothing
End Sub
and after comparing them, cycle through the collection and
print any page with revisions. The trouble is it seems to
get hung up on certain revisions when stepping through the
collection and Word stops responding. Debug.Print
statements show it gets hung up when the code tries to get
the page number of a particular revision. The bare bones
code, stripped down to its essence, is:
Public Sub CompAndPrint(strDoc1 As String, _
strDoc2 As String)
Dim objWordApp As Word.Application
Dim objRev As Word.Revision
Dim intLastPagePrinted As Integer
Dim intCurrentRevPage As Integer
Dim strPageList As String
Set objWordApp = New Word.Application
With objWordApp
.DisplayAlerts = wdAlertsNone
.Documents.Open FileName:=strDoc1, _
AddToRecentFiles:=False '1st document
.ActiveDocument.Compare Name:=strDoc2 'compare with 2nd
intLastPagePrinted = 0
For Each objRev In .ActiveDocument.Revisions
intCurrentRevPage = _
objRev.Range.Information(wdActiveEndPageNumber)
'check if added to page list yet
If intLastPagePrinted <> intCurrentRevPage Then
intLastPagePrinted = intCurrentRevPage
strPageList = strPageList & _
Format$(intLastPagePrinted) & ","
End If
Next objRev
strPageList = Left$(strPageList, _
-1 + Len(strPageList)) 'remove last ,
'now print
.PrintOut FileName:="", Range:=wdPrintRangeOfPages, _
Item:=wdPrintDocumentContent, Copies:=1, _
Pages:=strPageList, PageType:=wdPrintAllPages, _
Collate:=False, Background:=False, _
PrintToFile:=False, _
PrintZoomColumn:=0, PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
'close, don't save
.ActiveDocument.Close wdDoNotSaveChanges
End With
objWordApp.Quit
Set objWordApp = Nothing
End Sub