Export Word Track Changes to a Table with VBA
Question details
Export tracked revisions from a Word document into a table that includes their type, location, and surrounding text.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- A document contains many tracked insertions and deletions that need to be reviewed in a separate table.
- Observed behavior
- The desired output is one table row per revision, with page, line, action, prefix, revision text, and suffix.
Open the document in desktop Microsoft Word and confirm that it contains tracked revisions under Review. Make sure your organization's macro settings allow you to run trusted VBA code.
Export revisions with a Word VBA macro
Create a new Word document with one table row for each tracked revision and up to three surrounding words on each side.
Page and line values depend on Word's current layout and revision display. The surrounding ranges can include other tracked changes, so they do not necessarily represent only the final revised text.
Insertions and deletions are labeled explicitly; other revision types are identified by their numeric Word revision type. Complex or overlapping changes may require additional processing.
In desktop Word, open the document to analyze, then select Developer > Visual Basic. If the Developer tab is hidden, use Word's ribbon customization settings to enable it.
In the VBA editor, select a suitable project, choose Insert > Module, and paste the following code into the module: Sub ExportRevisionsToTable() Dim src As Document, report As Document Dim rev As Revision, pos As Range, ctx As Range Dim tbl As Table Dim rowNum As Long, action As String Const contextWords As Long = 3 Set src = ActiveDocument If src.Revisions.Count = 0 Then MsgBox "No tracked revisions found." Exit Sub End If Set report = Documents.Add Set tbl = report.Tables.Add(report.Range(0, 0), src.Revisions.Count + 1, 6) tbl.Cell(1, 1).Range.Text = "Page" tbl.Cell(1, 2).Range.Text = "Line" tbl.Cell(1, 3).Range.Text = "Action" tbl.Cell(1, 4).Range.Text = "Prefix" tbl.Cell(1, 5).Range.Text = "Revision" tbl.Cell(1, 6).Range.Text = "Suffix" rowNum = 2 For Each rev In src.Revisions Set pos = rev.Range.Duplicate pos.Collapse Direction:=wdCollapseStart tbl.Cell(rowNum, 1).Range.Text = CStr(pos.Information(wdActiveEndPageNumber)) tbl.Cell(rowNum, 2).Range.Text = CStr(pos.Information(wdFirstCharacterLineNumber)) Select Case rev.Type Case wdRevisionInsert: action = "Insertion" Case wdRevisionDelete: action = "Deletion" Case Else: action = "Other type " & CStr(rev.Type) End Select tbl.Cell(rowNum, 3).Range.Text = action Set ctx = rev.Range.Duplicate ctx.Collapse Direction:=wdCollapseStart ctx.MoveStart Unit:=wdWord, Count:=-contextWords tbl.Cell(rowNum, 4).Range.Text = CleanRevisionText(ctx.Text) tbl.Cell(rowNum, 5).Range.Text = CleanRevisionText(rev.Range.Text) Set ctx = rev.Range.Duplicate ctx.Collapse Direction:=wdCollapseEnd ctx.MoveEnd Unit:=wdWord, Count:=contextWords tbl.Cell(rowNum, 6).Range.Text = CleanRevisionText(ctx.Text) rowNum = rowNum + 1 Next rev End Sub Private Function CleanRevisionText(ByVal value As String) As String value = Replace(value, Chr(13), " ") value = Replace(value, Chr(7), " ") value = Replace(value, Chr(11), " ") CleanRevisionText = value End Function
Return to the source document, select Developer > Macros, choose ExportRevisionsToTable, and select Run. Word creates a separate document containing the table.
Check the new document's page numbers, line numbers, and context, especially around overlapping changes. Select File > Save As to save the report.

Review revision reports in WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility for an easy transition. Open and review the exported revision table in WPS Writer; the Word-specific VBA macro itself must be run in Microsoft Word.

Frequently Asked Questions
How can I include more words around each revision?
In the VBA module, change the value of contextWords from 3 to the number of words you want on each side, then run ExportRevisionsToTable again.
Why does the context include another tracked change?
The macro takes nearby Word ranges without filtering out other revisions. Producing context solely from the final revised version requires additional processing, particularly for overlapping changes.
Why do page or line numbers differ from what I see?
Word calculates these values from its current layout and revision display. Check the document's Review display settings and pagination before running the export.
Does the macro export formatting changes too?
Yes. It loops through ActiveDocument.Revisions, so revisions other than insertions and deletions are also listed. Those entries are labeled with their numeric revision type.
Can WPS Writer run this exact Word macro?
The example uses Microsoft Word's VBA object model and is intended for desktop Word. You can save the resulting table as a DOCX file and open it in WPS Writer.




