This macro (with minor changes, it likely originated on a Stack Exchange site) is fairly popular with authors that need to convert lots of tracked changes to regular text that has been colored blue:
Sub accept_changes()
tempState = ActiveDocument.TrackRevisions
ActiveDocument.TrackRevisions = False
For Each Revision In ActiveDocument.Revisions
Set Change = Revision.Range
Change.Revisions.AcceptAll
Change.Font.Color = 12611584
Next
ActiveDocument.TrackRevisions = tempState
End Sub
However, when using other macros or plug-ins such as Zotero it generates errors such as the following one:
Run-time error '5825': Object has been deleted
On the line with Set Change = Revision.Range, watching the code at debug shows that the Revision variable is of type Variant/Empty and all of the values (e.g., Revision.Range) are set to <Object has been deleted> in the Watches window. The field code encoding in the document at the point where the error occurs is ({ REF Ref87607402 \h \* MERGEFORMAT }).
Based upon stepping through the code this error seems to arise when citations or cross reference codes are inserted into the text, rendering creation of a SSCCE extremely difficult since the error has the properties of a heisenbug. However, for a document with 100's of changes, even being able to just bypass the error to move on to the next error would be useful.
Accordingly, how can you test for a deleted object in VBA, or conversely, bypass a deleted object to move onto the next revision in the document?
