VBA Code
Merges the changes marked with revision marks from one document to another.
Dim objDocument As Document
objDocument.Merge(Name:=
MergeTarget:=wdMergeTarget.wdMergeTargetNew
DetectFormatChanges:=False
UseFormattingFrom:=wdUseFormattingFrom.wdFormattingFromCurrent
AddToRecentFiles:=False
MergeTarget -
DetectFormatChanges - Whether to detect formatting changes in the document.
UseFormattingFrom -
AddToRecentFiles - Whether to add to the recent files list.
Set objRange = ActiveDocument.Comments(1).Range
ActiveDocument.AcceptAllRevisions
ActiveDocument.Revisions.AcceptAll
Displaying the Comments Pane
By default, Word 2003 and Word 2002 do not include the Comment pane feature.
ActiveDocument.ActiveWindow.View.SplitSpecial = wdSpecialPane.wdPaneComments
TrackRevisions Property
This property is True when tracked changes have been switched on in a document
ActiveDocument.TrackRevisions
The following lines of code switch tracked changes on in the active document and display the Revisions on screen
ActiveDocument.TrackRevisions = True
ActiveDocument.ShowRevisions = True
VBA - Comparing
Compares two documents and returns a Document object that represents the document that contains the differences between the two documents, marked using tracked changes.
Dim oResult As Word.Document
Set oResult = Application.CompareDocuments( _
OriginalDocument:=Documents(strDoc_1_FullName), _
RevisedDocument:=Documents(strDoc_2_FullName), _
Destination:=wdCompareDestination.wdCompareDestinationNew, _
Granularity:=wdGranularity.wdGranularityCharLevel, _
CompareFormatting:=False, _
CompareCaseChanges:=True, _
CompareWhitespace:=True, _
CompareTables:=True, _
CompareHeaders:=False, _
CompareFootnotes:=False, _
CompareTextboxes:=False, _
CompareFields:=True, _
CompareComments:=True, _
CompareMoves:=False, _
RevisedAuthor:=Application.UserName, _
IgnoreAllComparisonWarnings:=True)
OriginalDocument - Specifies the path and file name of the original document.
RevisedDocument - Specifies the path and file name of the revised document to which to compare the original document.
Destination - Specifies whether to create a new file or whether to mark the differences between the two documents in the original document or in the revised document. Default value is wdCompareDestinationNew.
Granularity - Specifies whether changes are tracked by character or by word. Default value is wdGranularityWordLevel.
CompareFormatting - Specifies whether to mark differences in formatting between the two documents. Default value is True.
CompareCaseChanges - Specifies whether to mark differences in case between the two documents. Default value is True.
CompareWhitespace - Specifies whether to mark differences in white space, such as paragraphs or spaces, between the two documents. Default value is True.
CompareTables - Specifies whether to compare the differences in data contained in tables between the two documents. Default value is True.
CompareHeaders - Specifies whether to compare differences in headers and footers between the two documents. Default value is True.
CompareFootnotes - Specifies whether to compare differences in footnotes and endnotes between the two documents. Default value is True.
CompareTextboxes - Specifies whether to compare differences in the data contained within text boxes between the two documents. Default value is True.
CompareFields - Specifies whether to compare differences in fields between the two documents. Default value is True.
CompareComments - Specifies whether to compare differences in comments between the two documents. Default value is True.
CompareMoves - Specifies whether to compare differences in moves between the two documents. Default value is True.
RevisedAuthor - Specifies the name of the person to whom to attribute changes when comparing the two documents.
IgnoreAllComparisonWarnings - Specifies whether to ignore warnings when comparing the two documents.
Public Sub Testing_CompareDocs()
Dim oOriginalDoc As Word.Document
Dim oRevisedDoc As Word.Document
Dim oResult As Word.Document
Dim sfolderpath As String
sfolderpath = "C:\Temp\Compare Documents\"
Set oOriginalDoc = Documents.Open(sfolderpath & "Original.docx", , False)
Set oRevised = Documents.Open(sfolderpath & "Revised.docx", , False)
Set oResult = Application.CompareDocuments( _
OriginalDocument:=oOriginalDoc, _
RevisedDocument:=oRevisedDoc, _
Destination:=wdCompareDestinationNew)
End Sub
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrev