Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB script for comparing Word documents

Status
Not open for further replies.

TuomasKemppainen

Programmer
Jun 27, 2019
1
0
0
FI
Hi,

I have tried to create script to compare word documents. I can make a working macro in Word but when trying to do the same in VB script I'm getting error "Expected statement" for the Application.CompareDocuments row. Below is the code I'm using. Any ideas how to make this work?



Set objWord = CreateObject("Word.Application")
objWord.DisplayAlerts = WdAlertsNone
objWord.Visible = True


'Opening original and revised files
Set ORIGINAL = objWord.Documents.Open("T:\user\Tuomas.Kemppainen\00_ROOT\99_PLAYGROUND\comparefiles\original.rtf",,False)
Set REVISED = objWord.Documents.Open("T:\user\Tuomas.Kemppainen\00_ROOT\99_PLAYGROUND\comparefiles\revised.rtf",,False)


'Comparing files
Application.CompareDocuments OriginalDocument := "T:\user\Tuomas.Kemppainen\00_ROOT\99_PLAYGROUND\comparefiles\original.rtf", _
RevisedDocument := "T:\user\Tuomas.Kemppainen\00_ROOT\99_PLAYGROUND\comparefiles\original.rtf", _
Destination := wdCompareDestinationNew, _
Granularity := wdGranularityCharLevel, _
CompareFormatting := True, _
CompareCaseChanges := True, _
CompareWhitespace := True, _
CompareTables := True, _
CompareHeaders := True, _
CompareFootnotes := True, _
CompareTextboxes := True, _
CompareFields := True, _
CompareComments := True, _
CompareMoves := True, _
RevisedAuthor := "TuomasK", _
IgnoreAllComparisonWarnings := False


'Save As RTF, RTF format is 6
'objWord.SaveAs WORD_COMPARE, 6


'Close original and revised files
ORIGINAL.Close False
REVISED.Close False
objWord.Quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top