MS Word - working with tracked changes in VBA

trf

Board Regular
Joined
Apr 17, 2002
Messages
62
I've got this code I am trying to use to accept only changes made by a certain author in MS Word:

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
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
TRF, I've just come across your post whilst researching the same (or similar) issue. I don't have a solution only a bit more info. My code stopped when it came across an addition by an author other than myself (although it later passed through all occurrences of this author) that was inside a Word table.

I have now manually accepted teh edit and run the code OK but still don't know why it fell at this fence.

Miles
 
Upvote 0

Forum statistics

Threads
1,216,385
Messages
6,130,314
Members
449,572
Latest member
mayankshekhar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top