2 // TortoiseSVN Merge script for Word Doc files
\r
4 // Copyright (C) 2004-2008 the TortoiseSVN team
\r
5 // This file is distributed under the same license as TortoiseSVN
\r
8 // $Author: steveking $
\r
9 // $Date: 2008-07-26 14:49:59 +0800 (Sat, 26 Jul 2008) $
\r
13 // Dan Sheridan, 2008
\r
14 // Davide Orlandi and Hans-Emil Skogh, 2005
\r
17 var objArgs,num,sTheirDoc,sMyDoc,sBaseDoc,sMergedDoc,objScript,word,baseDoc,WSHShell;
\r
19 var vbExclamation = "!"; //+pa
\r
21 objArgs = WScript.Arguments;
\r
22 num = objArgs.length;
\r
25 WScript.Echo("Usage: [CScript | WScript] merge-doc.js merged.doc theirs.doc mine.doc base.doc");
\r
29 sMergedDoc=objArgs(0);
\r
30 sTheirDoc=objArgs(1);
\r
31 sMyDoc=objArgs(2); //?? unused??
\r
32 sBaseDoc=objArgs(3);
\r
34 objScript = new ActiveXObject("Scripting.FileSystemObject")
\r
35 if ( ! objScript.FileExists(sTheirDoc))
\r
37 WScript.Echo("File " + sTheirDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found");
\r
40 if ( ! objScript.FileExists(sMergedDoc))
\r
42 WScript.Echo("File " + sMergedDoc +" does not exist. Cannot compare the documents.", vbExclamation, "File not found");
\r
50 word = WScript.CreateObject("Word.Application");
\r
54 WScript.Echo("You must have Microsoft Word installed to perform this operation.");
\r
60 // Open the base document
\r
61 baseDoc = word.Documents.Open(sTheirDoc); //?? base or their??
\r
63 // Merge into the "My" document
\r
64 if (Number(word.Version) < 12)
\r
66 baseDoc.Compare(sMergedDoc);
\r
68 baseDoc.Merge(sMergedDoc);
\r
71 // Show the merge result
\r
72 if (Number(word.Version) < 12)
\r
74 word.ActiveDocument.Windows(1).Visible = 1;
\r
77 // Close the first document
\r
78 if (Number(word.Version) >= 10)
\r
83 // Show usage hint message
\r
84 WSHShell = WScript.CreateObject("WScript.Shell");
\r
85 if(WSHShell.Popup("You have to accept or reject the changes before\nsaving the document to prevent future problems.\n\nWould you like to see a help page on how to do this?", 0, "TSVN Word Merge", 4 + 64) == 6)
\r
87 WSHShell.Run("http://office.microsoft.com/en-us/assistance/HP030823691033.aspx");
\r