Compare Word Documents using VBA
Here is a simple routine, which will compare two Microsoft Word documents and return the status.
Sub IsDocument_Equal()
Dim oDoc1 As Word.Document
Dim oResDoc As Word.Document
' Delete the tables from both the document
' Delete the images from both the document
' Replace Paragraphs etc
Set oDoc1 = ActiveDocument
' comparing Document 1 with New 1.doc
oDoc1.Compare Name:="C:\New 1.doc", CompareTarget:=wdCompareTargetNew, DetectFormatChanges:=True
'This will be the result document
Set oResDoc = ActiveDocument
If oResDoc.Revisions.Count <> 0 Then
'Some changes are done
MsgBox "There are Changes "
Else
MsgBox "No Changes"
End If
End Sub
how to make it user friendly like... instead of assigning path in pgm , we shall get from user
ReplyDeleteHi Everyone,
ReplyDeleteI've recorded a macro that compares 2 documents but after editing the code I was prompted with an error. can anyone help me to correct this code?
'ChangeFileOpenDirectory ""
'ChangeFileOpenDirectory ""
Application.CompareDocuments OriginalDocument:=Documents( _
"C:\Users\AAA\Desktop\Transcribed\VT290115.doc"), RevisedDocument:=Documents( _
"C:\Users\AAA\Desktop\Edited\VT290115.doc"), Destination:=wdCompareDestinationNew, Granularity _
:=wdGranularityWordLevel, CompareFormatting:=True, CompareCaseChanges:= _
True, CompareWhitespace:=True, CompareTables:=True, CompareHeaders:=True, _
CompareFootnotes:=True, CompareTextboxes:=True, CompareFields:=True, _
CompareComments:=True, CompareMoves:=True, RevisedAuthor:="Author", _
IgnoreAllComparisonWarnings:=False