8
votes

I work with a lot of revisions in Word 2010 (multiple authors with track changes on). I'd like to create a way to accept all deletions in a document without accepting the insertions. I did some research and found a VBA script example that claimed to do this but it just gave me an error message. It was a couple weeks ago and I can't find the script or remember the error message.

Anyone know how to do this? Thanks in advance.

SOLUTION:

Found the code I was using and for some reason it's working now.

Sub AcceptDeletion()
Dim oChange As Revision
For Each oChange In ActiveDocument.Revisions
  With oChange
   If .Type = wdRevisionDelete Then
     .Accept
   End If
  End With
Next oChange
End Sub
2
What error message? The code works fine as is. - ForEachLoop

2 Answers

1
votes

You could be more tidy if for :

With oChange
   If .Type = wdRevisionDelete Then
     .Accept
   End If
End With

you were to say:

If oChange.Type = wdRevisionDelete Then oChange.Accept
0
votes

The script above kept throwing an "Object has been deleted" error at me because the collection was modified during the loop. This one worked for me:

Sub AcceptDeletions()
Dim oChange As Revision
For i = ActiveDocument.Revisions.Count To 1 Step -1
If ActiveDocument.Revisions(i).Type = wdRevisionDelete Then
ActiveDocument.Revisions(i).Accept
End If
Next i
End Sub