Revision Object

S

Stephen

From Word 2003, when I run the code to loop through all revisons marks, I
get an error "object is required" in some cases. So what should I do to
avoid this error? Any help would be appreciated.

For Each oRev In Application.ActiveDocument.Revisions

If Not (oRev Is Nothing) Then

If oRev.Type = wdRevisionDelete Or oRev.Type =
wdRevisionInsert Or oRev.Type = wdRevisionReplace Then
If strUser = "" And strDate = "" And bIsCheckHighlight
Then
oRev.Range.HighlightColorIndex = m_colorHighlight
ElseIf Not (strUser = "") And bIsCheckHighlight Then
If UCase(oRev.Author) = UCase(strUser) Then
oRev.Range.HighlightColorIndex = m_colorHighlight
ElseIf Not (UCase(oRev.Author) = UCase(strUser)) Then
oRev.Range.HighlightColorIndex = wdNoHighlight
End If
ElseIf Not (strDate = "") And bIsCheckHighlight Then
If DateValue(oRev.Date) = DateValue(CDate(strDate))
Then
oRev.Range.HighlightColorIndex = m_colorHighlight
End If
Else
oRev.Range.HighlightColorIndex = wdNoHighlight
End If

End If

'If MsgBox(Print_Debug(oRev), vbOKCancel) = vbCancel Then
'Exit Sub
'End If

End If

Next oRev


Thanks in advance.
 
G

George Lee

The code sample runs fine on my samples (but that’s not saying much since
documents vary so much). However, there are known problems with revisions,
mainly that the internal link list gets corrupted over time. This is seen by
either entering a endless loop as it points back to itself, or the pointer
goes off to random location. Without more information, the problem is likely
to the second case, a bad pointer. The fix is difficult. The revision list
can’t be patched or repaired, short of deleting all revisions.

A more convenient workaround is to include an error handler that attempts to
skip the problem. In writing this handling, you should count the consecutive
times the error is hit (getting more than several, such as 100 indicates
you’ve entered a loop or bad pointer. Another option is to use a indexed for
loop based on the revisions count; but that’s not necessarily a much better
fix. Finally, try restarting the revision list at an arbitrary point such as
the one third position, or the half way point, hoping to skip the bad links.
Other than that, the news isn’t good.
 

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