Word Macro: Accepting All Tracked Changes in All Docments

This Word VBA macro accepts all track changes in all documents.

Macro Example

Sub AcceptAllChangesInAllDocuments() 

  Dim doc As Document

 For Each doc In Documents
    doc.Revisions.AcceptAll
 Next doc

End Sub

Description

Variable Declaration

Sub...

  Dim doc As Document

The 3rd line declares an object variable named doc that will refer to the Document object.

The Document object represents a single Word document.

obj-Word-Document

Starts Looping

Sub...

  Dim doc As Document

 For Each doc In Documents

The 5th line starts to loop through all the elements (Document) of a collection (Documents).

[Application.]Documents

The [Application.]Documents property returns the Documents collection object.

obj-Word-Application-Documents

The Documents property is a member of the Word.Global class, so we can omit the Application property.

obj-Word-Documents

The Documents is a collection of all the Document objects those are currently open in Word.

obj-Word-Documents

Accepts All Changes Each Document

Sub...

  Dim doc As Document

 For Each doc In Documents
    doc.Revisions.AcceptAll

The 6th line accepts all track changes.

Document.Revisons

  doc.Revions...

The Document.Revisions property returns a Revisions collection object that represents the tracked changes in the document.

obj-Word-Document-Revisions

Revisons.AcceptAll

  doc.Revions.AcceptAll

We can accepts all the tracked changes in a document by the Revisions.AcceptAll method.

obj-Word-Revisions-AcceptAll

Loops Back

Sub...

  Dim doc As Document

 For Each doc In Documents
    doc.Revisions.AcceptAll
 Next doc

The 7th line loops back to get the next document.

After every document is evaluated, this macro ends.

Sub AcceptAllChangesInAllDocuments() 

  Dim doc As Document

 For Each doc In Documents
    doc.Revisions.AcceptAll
 Next doc

End Sub

Properties

http://www.relief.jp/itnote/archives/word-vba-accept-all-changes.php

Apply To

  • Word 2013
  • Word 2010
  • Word 2007