Handle Track Changes in Word with Macros
This article provides macros and VBA code snippets that may help you if you are going to create Word macros to handle some operations in relation to Track Changes in Word.
You will find detailed information about how track changes works in my how-it-works article on my website wordaddins.com. The macro code below is related to that article.
IMPORTANT: The macro code in this article is made for Word 2013 and newer versions of Word. Some of the code will result in errors if used in Word 2010 and earlier versions due to changes to the Track Changes features that Microsoft introduced in Word 2013.
MACRO – Reset Advanced Track Changes Options to default
The Advanced Track Changes Options dialog box is used to define which types of changes are tracked and how tracked changes appear for the individual user.
You will find detailed information about the Advanced Track Changes Options dialog box, incl. an illustration showing the default settings, in my how-it-works article on my website wordaddins.com.
The macro below reverts the dialog box to the default settings. If you examine the code, you should be able to adjust it to other setting than the default if desired.
Comments in the macro code explain how the code relates to the dialog box.
Sub AdvancedTrackChangesOptions_SetToDefault()
'Macro created by Lene Fredborg, Aug-2020
'Works with Word 2013 and newer versions PC/Windows
'This macro resets all settings in Advanced Track Changes Options to default
'The code is organized as in the dialog box for easy reference
With Options
'MARKUP group
'Insertions
.InsertedTextMark = wdInsertedTextMarkUnderline
.InsertedTextColor = wdByAuthor
'Deletions
.DeletedTextMark = wdDeletedTextMarkStrikeThrough
.DeletedTextColor = wdByAuthor
'Changed lines
.RevisedLinesMark = wdRevisedLinesMarkOutsideBorder
'Comments
.CommentsColor = wdByAuthor
'MOVES group
'Track moves
ActiveDocument.TrackMoves = True
'Moved from
.MoveFromTextMark = wdMoveFromTextMarkDoubleStrikeThrough
.MoveFromTextColor = wdGreen
'Moved to
.MoveToTextMark = wdMoveToTextMarkDoubleUnderline
.MoveToTextColor = wdGreen
'TABLE CELL HIGHLIGHTING group
'Inserted cells
.InsertedCellColor = wdCellColorLightBlue
'Deleted cells
.DeletedCellColor = wdCellColorPink
'Merged cells
.MergedCellColor = wdCellColorLightYellow
'Split cells
.SplitCellColor = wdCellColorLightOrange
'FORMATTING group
'Track formatting
ActiveDocument.TrackFormatting = True
'Formatting
.RevisedPropertiesMark = wdRevisedPropertiesMarkNone
.RevisedPropertiesColor = wdByAuthor
End With
With ActiveWindow.View
'BALLOONS group
'Preferred width
'Measure in (must be set before setting value)
.RevisionsBalloonWidthType = wdBalloonWidthPoints
'set depending on unit of measurement measurement
If Options.MeasurementUnit = wdCentimeters Then
.RevisionsBalloonWidth = CentimetersToPoints(9.4)
Else
.RevisionsBalloonWidth = InchesToPoints(3.7)
End If
'Margin
.RevisionsBalloonSide = wdRightMargin
'Show lines connection to text
.RevisionsBalloonShowConnectingLines = True
End With
With Options
'Paper orientation in printing
.RevisionsBalloonPrintOrientation = wdBalloonPrintOrientationPreserve
End With
End SubVBA code snippets for misc. Track Changes operations
Below, you will find several small VBA code snippets that may help you create your own macros for handling tracked changes.
Macro code – Turn Track Changes on and off
'Turn on Track Changes
ActiveDocument.TrackRevisions = True
'Turn off Track Changes
ActiveDocument.TrackRevisions = FalseMacro code – Count number of tracked changes and comments
Dim lngCount As Long
'Count number of tracked changes
lngCount = ActiveDocument.Revisions.Count
'Count number of comments
lngCount = ActiveDocument.Comments.Count
Macro code – Turn on/off Track Moves and Track Formatting in Advanced Track Changes Options
NOTE: Track Moves and Track formatting are document-specific settings that are saved in the document. All other options in the Advanced Track Changes Options dialog box apply to all Word documents. For details, see my comprehensive track changes article.
'Turn on Track Moves
ActiveDocument.TrackMoves = True
'Turn off Track Moves
ActiveDocument.TrackMoves = False
'Turn on Track Formatting
ActiveDocument.TrackFormatting = True
'Turn off Track Formatting
ActiveDocument.TrackFormatting = FalseMacro code – Set Simple Markup, All Markup, No Markup, or Original
The code snippets below help you set options in the Display for Review menu.
'Select Display for Review > Simple Markup
With ActiveWindow.View.RevisionsFilter
.Markup = wdRevisionsMarkupSimple
.View = wdRevisionsViewFinal
End With
'Select Display for Review > All Markup
With ActiveWindow.View.RevisionsFilter
.Markup = wdRevisionsMarkupAll
.View = wdRevisionsViewFinal
End With
'Select Display for Review > No Markup
With ActiveWindow.View.RevisionsFilter
.Markup = wdRevisionsMarkupNone
.View = wdRevisionsViewFinal
End With
'Select Display for Review > Original
With ActiveWindow.View.RevisionsFilter
.Markup = wdRevisionsMarkupNone
.View = wdRevisionsViewOriginal
End WithMacro code – Show the Revision Pane
'Show Revisions Pane Vertical
ActiveWindow.View.SplitSpecial = wdPaneRevisionsVert
'Show Revisions Pane Horizontal
ActiveWindow.View.SplitSpecial = wdPaneRevisionsHorizMacro code – Accept and reject tracked changes
'Accept all tracked changes in the active document
ActiveDocument.Revisions.AcceptAll
'Reject all tracked changes in the active document
ActiveDocument.Revisions.RejectAll
'Accept all tracked changes in the selection
Selection.Range.Revisions.AcceptAll
'Reject all tracked changes in the selection
Selection.Range.Revisions.RejectAllMacro code – Display of tracked changes and comments (revisions)
'Show revisions and comments, i.e. all types of tracked changes and comments
ActiveWindow.View.ShowRevisionsAndComments = True
'Hide revisions and comments
ActiveWindow.View.ShowRevisionsAndComments = False
'Show insertions and deletions (without changing comments display)
ActiveWindow.View.ShowInsertionsAndDeletions = True
'Hide insertions and deletions (without changing comments display)
ActiveWindow.View.ShowInsertionsAndDeletions = False
'Show comments
ActiveWindow.View.ShowComments = True
'Hide comments
ActiveWindow.View.ShowComments = False
'Show formatting changes
ActiveWindow.View.ShowFormatChanges = True
'Hide formatting changes
ActiveWindow.View.ShowFormatChanges = FalseMacro code – Select options in Show Markup > Balloons
'Select Show Markup - Balloons - Show Revisions in Balloons
ActiveWindow.View.MarkupMode = wdBalloonRevisions
'Select Show Markup - Balloons - Show all Revisions Inline
ActiveWindow.View.MarkupMode = wdInLineRevisions
'Select Show Markup - Balloons - Show Only Comments and Formatting in Balloons
ActiveWindow.View.MarkupMode = wdMixedRevisions
Macro code – Turn on/off Trust Center settings related to tracked changes and comments
'Turn on Warn before printing, saving or sending a file
'that contains tracked changes or comments
Options.WarnBeforeSavingPrintingSendingMarkup = True
'Turn off "Warn before printing, saving or sending a file
'that contains tracked changes or comments"
Options.WarnBeforeSavingPrintingSendingMarkup = False
'Turn on "Make hidden markup visible when opening or saving"
Options.ShowMarkupOpenSave = True
'Turn off "Make hidden markup visible when opening or saving"
Options.ShowMarkupOpenSave = False
Related information
See About VBA Macros and Code Snippets and How to Install a Macro for basic information about the macros available on this website and for information about how to install macros.
Macro to extract tracked changes from Word.
Macro to extract comments from Word.
Detailed article about how track changes works on my wordaddins.com website.