Mohamad Bachrouche
Mohamad Bachrouche

Reputation: 131

How to Accept All Changes In Selection?

I am trying to accept all changes in a selection, in Word 2013.

I used the macro recorder and it generated the following code (it can also be found at https://learn.microsoft.com/en-us/office/vba/api/word.revisions.acceptall)

Selection.Range.Revisions.AcceptAll

However, it will not work unless I physically select each letter

enter image description here
enter image description here

But if I use the built in buttons in the 'Changes' group within the 'Review' tab, I don't have to physically select the entire letter. I just need to select any part of the change and it will accept the change.

enter image description here
enter image description here

Why does the macro version not perform like the UI option?

Upvotes: 1

Views: 705

Answers (1)

Dick Kusleika
Dick Kusleika

Reputation: 33145

That is odd behavior. The UI must be doing something like the below, but whoever built the macro recorder missed it.

Public Sub AcceptSelection()
    
    Dim rev As Revision
    
    For Each rev In Selection.Range.Revisions
        rev.Accept
    Next rev
    
End Sub

That code will accept any revisions in the selection, even partial ones.

Upvotes: 1

Related Questions