Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Word VBA script to accept all deletions?

Tags:

ms-word

vba

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
like image 332
Tote Avatar asked Jan 18 '11 20:01

Tote


People also ask

Is there a way to accept all deletions in Word?

Accept or reject all changes Go to the Review tab. Do one of the following: Changes and do one of the following: In the Accept drop-down list, select Accept All Changes. In the Reject drop-down list, select Reject all Changes.

How do I accept all changes in a selection in Word?

Tip: To accept or reject changes all at once, click the arrow on the Accept or Reject button, and then choose Accept All Changes or Reject All Changes.

How do I get Word to automatically accept all format changes?

Accept or reject all changes at once Place the pointer at the beginning of the document. To accept all changes, select Review, select the arrow below Accept, and then select Accept All Changes. To reject all changes, select Review, select the arrow below Reject, and then select Reject All Changes.


1 Answers

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
like image 62
smitty1e Avatar answered Sep 16 '22 14:09

smitty1e