I've got this code I am trying to use to accept only changes made by a certain author in MS Word:
It works fine on some documents, but on other docs it hiccups, breaking with a run-time error: "Method 'Author' of object 'Revision' failed." I've stepped through the code watching the locals window and the problem seems to be that the rev object gets deleted after revision #72 (of over 1500), so when we come back to the line "If rev.author = " rev.author is undefined since the object was deleted. Revision #73 is a formatting change only (changing the line spacing), but there's nothing unique about that; Word cycled through other tracked formatting changes with no problem.
Has anyone experienced anything like this before, or worked enough with the Revision object to have any insight?
Thanks!
Rob
Code:
Sub MakeRevisions()
Dim rev As Revision
Debug.Print ActiveDocument.Revisions.Count
If ActiveDocument.Revisions.Count > 0 Then
For Each rev In ActiveDocument.Revisions
If rev.Author = "trf" Then
rev.Accept
End If
Next rev
End If
End Sub
It works fine on some documents, but on other docs it hiccups, breaking with a run-time error: "Method 'Author' of object 'Revision' failed." I've stepped through the code watching the locals window and the problem seems to be that the rev object gets deleted after revision #72 (of over 1500), so when we come back to the line "If rev.author = " rev.author is undefined since the object was deleted. Revision #73 is a formatting change only (changing the line spacing), but there's nothing unique about that; Word cycled through other tracked formatting changes with no problem.
Has anyone experienced anything like this before, or worked enough with the Revision object to have any insight?
Thanks!
Rob