' ***************************************************
' Script To Invoke the MS Word Compare Docs
'
' Danny J. Lesandrini April 4, 2001
' datafast@home.com
http://datafast.cjb.net'
'
' This script will uses COM Automation to access
' the MS Office Object Model in order to use the
' MS Word Compare Documents routine on two files.
'
' The use is prompted for the paths of the two
' documents to be compared. If no values are
' supplied, the routine assumes that two sample
' files exist on the C:\ drive:
'
' "C:\MyDocA.txt"
' "C:\MyDocB.txt"
'
' I have added no validation code to verify that
' the path supplied by the user is valid.
'
' Note that the CreateObject call uses the generic
' reference, "Word.Application" with no version
' number. This assures that the script won't break
' just because the client machine doesn't contain
' the correct version of MS Word. The script
' will break, however, if no version of Word is
' found on the client machine
'
' ***************************************************
Dim objWord
Dim objScript
Dim strDocA
Dim strDocB
Dim fContinue
'Const vbExclamation = 48
strDocA = InputBox("Enter complete path first doc", "Compare")
strDocB = InputBox("Enter complete path second doc", "Compare")
' Assume that user passed valid paths
fContinue = True
' Now, test file paths to DocA and DocB for validity
' -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Set objScript = CreateObject("Scripting.FileSystemObject")
fContinue = objScript.FileExists(strDocA)
fContinue = objScript.FileExists(strDocB)
Set objScript = Nothing
If fContinue = False Then
MsgBox "Invalid File Paths" ,vbExclamation ,"Error"
Else
' Only continue if user has typed text into InputBox.
Set objWord = CreateObject("Word.Application")
objWord.Documents.Open strDocA
objWord.ActiveDocument.Compare strDocB
objWord.Visible = True
Set objWord = Nothing
End If