Fernando P. Nájera Cano wrote:
> Original script works too with several Office 2003. But...
> RM> 1) I moved the Word.Visible = True to the end of the
> RM> script because otherwise you get one Word window shortly
> RM> flashing.
> If you do that, in case of problems, you'll get an invisible instance
> of Word, which is not good. Users won't notice it, and they can end
> with a lot of Word.exe processes without knowing. I've got problems on
> normal.dot also when that happens.
Ah, I didn't thought about such a case or knew this.
> Maybe with better error handling it would be OK, but my vote is -1 for
> that change. I prefer Word flashing than a hidden Word instance until
> next reboot.
You're right, I reverted that change and added it again so Stefan can
commit this version.
Set objArgs = WScript.Arguments
num = objArgs.Count
if num < 2 then
MsgBox "Usage: [CScript | WScript] compare.vbs base.doc new.doc", vbExclamation, "Invalid arguments"
Set objScript = CreateObject("Scripting.FileSystemObject")
If objScript.FileExists(sBaseDoc) = False Then
MsgBox "File " + sBaseDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found"
If objScript.FileExists(sNewDoc) = False Then
MsgBox "File " + sNewDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found"
Set objScript = Nothing
On Error Resume Next
set word = createobject("Word.Application")
If Err.Number <> 0 Then
Wscript.Echo "You must have Microsoft Word installed to perform this operation."
On Error Goto 0
' Open the new document
set destination = word.Documents.Open(sNewDoc)
' Hide it
' Compare to the base document
' Show the comparison result
word.ActiveDocument.Windows(1).Visible = 1
' Mark the comparison document as saved to prevent the annoying
' "Save as" dialog from appearing.
word.ActiveDocument.Saved = 1
' Close the first document
To unsubscribe, e-mail: email@example.com
For additional commands, e-mail: firstname.lastname@example.org
Received on Fri Jul 8 20:36:47 2005