Extract Tracked Changes to New Document

You may wish to get en overview of tracked changes (revisions) in a document. You can print the changes by selecting List of Markup in the Print What field in the Print dialog box. However, you may want the overview in electronic form.

Here you will find both a macro, and introduction to an advanced Word add-in and a free Word add-in that let you extract the tracked changes to a new document. Note that only insertions and deletions will be included whereas other types of changes (formatting changes etc.) will be skipped. Also note that the macro and the free add-in will only include insertions and deletions found in the main body of the document whereas the advanced add-in will also include insertions and deletions found in headers, footers, footnotes and endnotes.

Instead of installing the macro available via this page you may be interested in one of the ready-to-use add-ins, DocTools ExtractChanges Pro or DocTools ExtractData. Below, you can read about both the add-ins and the macro.

Word add-ins ready for use

DocTools ExtractChanges Pro - advanced add-in for Word

DocTools ExtractChanges Pro is an advanced Word add-in that lets you extract insertions, deletions and comments in full context and including headings and subheadings.

Free Trial icon
Word Add-In from DocTools

The add-in works with Microsoft Word 2010 and newer versions on PC/Windows.

The add-in lets you quickly and easily extract data to a new document. The data, incl. additional metadata, will be listed in a table for easy overview.

DocTools ExtractChanges Pro is the perfect, time-saving tool for anyone who is editing large contracts and similar documents.

The add-in does not only extract tracked changes. The following applies to DocTools ExtractChanges Pro but not to the free add-in and the macro:

  • Insertions, deletions and comments are shown in full context in the extract document
  • The add-in extracts insertions and deletions both form the main body of the document and from headers, footers, footnotes and endnotes
  • Headings and subheadings are detected and extracted with the changes – even in poorly formatted Word documents (e.g. converted from PDF to Word)
  • You can customize several options in relation to the extract and the resulting document

You can access the functionality of the add-in from a custom tab in the Ribbon.

How to get the DocTools ExtractChanges Pro add-in

This advanced add-in is not free but the return on investment is almost immediate. Save hours of work already on the first use.

Click the button below to learn more about DocTools ExtractChanges Pro or to buy the add-in.

You can try DocTools ExtractChanges Pro risk-free for 7 days.

DocTools ExtractData - a free add-in for Word

Word Add-In from DocTools

DocTools ExtractData is a Word add-in I provide for free. It lets you extract acronyms, bookmarks, tracked changes and comments.

The add-in works with Microsoft Word 2007 and newer versions on PC/Windows.

The add-in lets you easily extract the following types of data from the active document to a new document:

  • acronyms
  • bookmarks
  • tracked changes
  • comments

The extracted data, incl. additional metadata, will be listed in a table for easy overview.

DocTools ExtractData adds a set of tools to a custom tab, DocTools, in the Ribbon. The tools can be accessed from the group Extract Data in the DocTools tab. The DocTools tab may also contain tools from other add-ins provided by DocTools.

The result of extracting acronyms, tracked changes and comments are slightly improved versions of the results you get by using the free macros available on this website. The functionality for extracting bookmarks is available in the add-in only.

How to get the DocTools ExtractData add-in for free

Click the button below to learn more about DocTools ExtractData. You can download the add-in for free.

Macro solution

Read below if you want to use the macro instead of one of the add-ins.

About the tracked changes document that is created

The document with the extracted tracked changes will include a header with the following information:

  • Full name of the document from which the changes were extracted
  • Name of the document creator
  • Creation date

The tracked changed and metadata will be filled into a 6-column table. For each tracked change, the table will show:

  • Page number
  • Line number
  • The type of change
  • The text that was inserted or deleted
  • stop
    Name of the author who made the change
  • stop
    The date the change was made

See the illustrations below.

Figure 1. Example of a document with changes made by different authors. In this example, the insertions and deletions are shown with underline/strikethrough. However, when running the macro, it does not matter how or whether tracked changes are shown.

The tracked changes from the example above have been extracted to a new document

Figure 2. The tracked changes from the example in Figure 1 have been extracted to a new document. If a footnote or endnote reference has been inserted or deleted, the text "[footnote reference]" or "[endnote reference]" will be shown where such reference was found. In order to make it easy to distinguish between deletions and insertions, inserted text will be applied black font color whereas deleted text will be applied red font color.

Note that you may need to change the table layout. Among other factors, the result will depend on your default table settings.

The macro

Below, you will find the macro code. If you need help on installing macros, see How to install a macro.

Public Sub ExtractTrackedChangesToNewDoc()

    '=========================
    'Macro created 2007 by Lene Fredborg, DocTools - www.thedoctools.com
    'THIS MACRO IS COPYRIGHT. YOU ARE WELCOME TO USE THE MACRO BUT YOU MUST KEEP THE LINE ABOVE.
    'YOU ARE NOT ALLOWED TO PUBLISH THE MACRO AS YOUR OWN, IN WHOLE OR IN PART.    
    '=========================
    'The macro creates a new document
    'and extracts insertions and deletions
    'marked as tracked changes from the active document
    'NOTE: Other types of changes are skipped
    '(e.g. formatting changes or inserted/deleted footnotes and endnotes)
    'Only insertions and deletions in the main body of the document will be extracted
    'The document will also include metadata
    'Inserted text will be applied black font color
    'Deleted text will be applied red font color
    
    'Minor adjustments are made to the styles used
    'You may need to change the style settings and table layout to fit your needs
    '=========================

    Dim oDoc As Document
    Dim oNewDoc As Document
    Dim oTable As Table
    Dim oRow As Row
    Dim oCol As Column
    Dim oRange As Range
    Dim oRevision As Revision
    Dim strText As String
    Dim n As Long
    Dim i As Long
    Dim Title As String
    
    Title = "Extract Tracked Changes to New Document"
    n = 0 'use to count extracted changes
    
    Set oDoc = ActiveDocument
    
    If oDoc.Revisions.Count = 0 Then
        MsgBox "The active document contains no tracked changes.", vbOKOnly, Title
        GoTo ExitHere
    Else
        'Stop if user does not click Yes
        If MsgBox("Do  you want to extract tracked changes to a new document?" & vbCr & vbCr & _
                "NOTE: Only insertions and deletions will be included. " & _
                "All other types of changes will be skipped.", _
                vbYesNo + vbQuestion, Title) <> vbYes Then
            GoTo ExitHere
        End If
    End If
        
    Application.ScreenUpdating = False
    'Create a new document for the tracked changes, base on Normal.dot
    Set oNewDoc = Documents.Add
    'Set to landscape
    oNewDoc.PageSetup.Orientation = wdOrientLandscape
    With oNewDoc
        'Make sure any content is deleted
        .Content = ""
        'Set appropriate margins
        With .PageSetup
            .LeftMargin = CentimetersToPoints(2)
            .RightMargin = CentimetersToPoints(2)
            .TopMargin = CentimetersToPoints(2.5)
        End With
        'Insert a 6-column table for the tracked changes and metadata
        Set oTable = .Tables.Add _
            (Range:=Selection.Range, _
            numrows:=1, _
            NumColumns:=6)
    End With
    
    'Insert info in header - change date format as you wish
    oNewDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = _
        "Tracked changes extracted from: " & oDoc.FullName & vbCr & _
        "Created by: " & Application.UserName & vbCr & _
        "Creation date: " & Format(Date, "MMMM d, yyyy")
            
    'Adjust the Normal style and Header style
    With oNewDoc.Styles(wdStyleNormal)
        With .Font
            .Name = "Arial"
            .Size = 9
            .Bold = False
        End With
        With .ParagraphFormat
            .LeftIndent = 0
            .SpaceAfter = 6
        End With
    End With
    
    With oNewDoc.Styles(wdStyleHeader)
        .Font.Size = 8
        .ParagraphFormat.SpaceAfter = 0
    End With
    
    'Format the table appropriately
    With oTable
        .Range.Style = wdStyleNormal
        .AllowAutoFit = False
        .PreferredWidthType = wdPreferredWidthPercent
        .PreferredWidth = 100
        For Each oCol In .Columns
            oCol.PreferredWidthType = wdPreferredWidthPercent
        Next oCol
        .Columns(1).PreferredWidth = 5  'Page
        .Columns(2).PreferredWidth = 5  'Line
        .Columns(3).PreferredWidth = 10 'Type of change
        .Columns(4).PreferredWidth = 55 'Inserted/deleted text
        .Columns(5).PreferredWidth = 15 'Author
        .Columns(6).PreferredWidth = 10 'Revision date
    End With

    'Insert table headings
    With oTable.Rows(1)
        .Cells(1).Range.Text = "Page"
        .Cells(2).Range.Text = "Line"
        .Cells(3).Range.Text = "Type"
        .Cells(4).Range.Text = "What has been inserted or deleted"
        .Cells(5).Range.Text = "Author"
        .Cells(6).Range.Text = "Date"
    End With
    
    'Get info from each tracked change (insertion/deletion) from oDoc and insert in table
    For Each oRevision In oDoc.Revisions
        Select Case oRevision.Type
            'Only include insertions and deletions
            Case wdRevisionInsert, wdRevisionDelete
                'In case of footnote/endnote references (appear as Chr(2)),
                'insert "[footnote reference]"/"[endnote reference]"
                With oRevision
                    'Get the changed text
                    strText = .Range.Text
                
                    Set oRange = .Range
                    Do While InStr(1, oRange.Text, Chr(2)) > 0
                        'Find each Chr(2) in strText and replace by appropriate text
                        i = InStr(1, strText, Chr(2))
                        
                        If oRange.Footnotes.Count = 1 Then
                            strText = Replace(Expression:=strText, _
                                    Find:=Chr(2), Replace:="[footnote reference]", _
                                    Start:=1, Count:=1)
                            'To keep track of replace, adjust oRange to start after i
                            oRange.Start = oRange.Start + i
                    
                        ElseIf oRange.Endnotes.Count = 1 Then
                            strText = Replace(Expression:=strText, _
                                    Find:=Chr(2), Replace:="[endnote reference]", _
                                    Start:=1, Count:=1)
                            'To keep track of replace, adjust oRange to start after i
                            oRange.Start = oRange.Start + i
                        End If
                   Loop
                End With
                'Add 1 to counter
                n = n + 1
                'Add row to table
                Set oRow = oTable.Rows.Add
                
                'Insert data in cells in oRow
                With oRow
                    'Page number
                    .Cells(1).Range.Text = _
                        oRevision.Range.Information(wdActiveEndPageNumber)
                    
                    'Line number - start of revision
                    .Cells(2).Range.Text = _
                        oRevision.Range.Information(wdFirstCharacterLineNumber)
                    
                    'Type of revision
                    If oRevision.Type = wdRevisionInsert Then
                        .Cells(3).Range.Text = "Inserted"
                        'Apply automatic color (black on white)
                        oRow.Range.Font.Color = wdColorAutomatic
                    Else
                        .Cells(3).Range.Text = "Deleted"
                        'Apply red color
                        oRow.Range.Font.Color = wdColorRed
                    End If
                    
                    'The inserted/deleted text
                    .Cells(4).Range.Text = strText
                    
                    'The author
                    .Cells(5).Range.Text = oRevision.Author
                    
                    'The revision date
                    .Cells(6).Range.Text = Format(oRevision.Date, "mm-dd-yyyy")
                End With
        End Select
    Next oRevision
    
    'If no insertions/deletions were found, show message and close oNewDoc
    If n = 0 Then
        MsgBox "No insertions or deletions were found.", vbOKOnly, Title
        oNewDoc.Close savechanges:=wdDoNotSaveChanges
        GoTo ExitHere
    End If
    
    'Apply bold formatting and heading format to row 1
    With oTable.Rows(1)
        .Range.Font.Bold = True
        .HeadingFormat = True
    End With
    
    Application.ScreenUpdating = True
    Application.ScreenRefresh
        
    oNewDoc.Activate
    MsgBox n & " tracked changed have been extracted. " & _
        "Finished creating document.", vbOKOnly, Title

ExitHere:
    Set oDoc = Nothing
    Set oNewDoc = Nothing
    Set oTable = Nothing
    Set oRow = Nothing
    Set oRange = Nothing
    
End Sub

Alternative method – print tracked changes to PDF

You can create a PDF file that contains the tracked changes. The layout and contents of the PDF file will correspond to the version you can print on paper by selecting "List of Markup" in the "Print What" field in the Print dialog box. In order to print to PDF instead of paper, you need to select the installed PDF printer (e.g. "Adobe PDF") in the Print dialog box.

Note that the exact look of the printed tracked changes depends on your currently selected options for tracked changes.

Related information

See About VBA Macros and Code Snippets and How to Install a Macro for misc. information that may help you in your work with macros and for information about how to install macros.

For a macro that can extract all comments from the active document, see Extract Comments to New Document.

For a macro that can extract ACRONYMS from the active document, see Extract ACRONYMS to New Document.

You may also be interested in MVP Shauna Kelly's article How does Track Changes in Microsoft Word work?.