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

Re: Word Diff Windows Scripting Host error (diff-doc.js)

From: Jared Silva <jayrod_at_gmail.com>
Date: Wed, 9 Jan 2008 18:14:33 -0500

This patch forces the file to open as read only.

This patch _also_ handles errors opening and errors comparing gracefully.

Index: diff-doc.js
===================================================================
@@ -104,7 +104,16 @@
 word.visible = true;

 // Open the new document
-destination = word.Documents.Open(sNewDoc);
+try
+{
+ destination = word.Documents.Open(sNewDoc, true, true);
+}
+catch(e)
+{
+ WScript.Echo("Error opening " + sNewDoc);
+ // Quit
+ WScript.Quit(1);
+}

 // If the Type property returns either wdOutlineView or wdMasterView
and the Count property returns zero, the current document is an
outline.
 if (((destination.ActiveWindow.View.Type == wdOutlineView) ||
(destination.ActiveWindow.View.Type == wdMasterView)) &&
(destination.Subdocuments.Count == 0))
@@ -117,12 +126,31 @@
 if (Number(word.Version) <= vOffice2000)
 {
     // Compare for Office 2000 and earlier
- destination.Compare(sBaseDoc);
+ try
+ {
+ destination.Compare(sBaseDoc);
+ }
+ catch(e)
+ {
+ WScript.Echo("Error comparing " + sBaseDoc + " and " + sNewDoc);
+ // Quit
+ WScript.Quit(1);
+ }
 }
 else
 {
     // Compare for Office XP (2002) and later
- destination.Compare(sBaseDoc, "Comparison", wdCompareTargetNew,
true, true);
+ try
+ {
+ destination.Compare(sBaseDoc, "Comparison",
wdCompareTargetNew, true, true);
+ }
+ catch(e)
+ {
+ WScript.Echo("Error comparing " + sBaseDoc + " and " + sNewDoc);
+ // Close the first document and quit
+ destination.Close(wdDoNotSaveChanges);
+ WScript.Quit(1);
+ }
 }

 // Show the comparison result

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_tortoisesvn.tigris.org
For additional commands, e-mail: users-help_at_tortoisesvn.tigris.org
Received on 2008-01-10 00:14:40 CET

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

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