[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [TSVN] VBScript for comparing two MS Word documents

From: Rainer Müller <mueller_rainer_at_gmx.de>
Date: 2005-07-08 20:36:20 CEST

Fernando P. Nájera Cano wrote:
> Hi,
> 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.


option explicit

dim objArgs,num,sBaseDoc,sNewDoc,objScript,word,destination

Set objArgs = WScript.Arguments
num = objArgs.Count
if num < 2 then
   MsgBox "Usage: [CScript | WScript] compare.vbs base.doc new.doc", vbExclamation, "Invalid arguments"
   WScript.Quit 1
end if


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"
    Wscript.Quit 1
End If
If objScript.FileExists(sNewDoc) = False Then
    MsgBox "File " + sNewDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found"
    Wscript.Quit 1
End If

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."
   Wscript.Quit 1
End If
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: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Fri Jul 8 20:36:47 2005

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.