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

Re: Excel diff script (extended version)

From: kippspan <kippspanbauer_at_yahoo.com>
Date: 2007-05-29 19:36:24 CEST

Tobias Schäfer wrote:
>
>
> Thanks, applied in revision 9553 and merged into 1.4.x in revision 9554
>
> Tobias
>
> --
> ___
> oo // \\ "De Chelonian Mobile"
> (_,\/ \_/ \ TortoiseSVN
> \ \_/_\_/> The coolest Interface to (Sub)Version Control
> /_/ \_\ http://tortoisesvn.net
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tortoisesvn.tigris.org
> For additional commands, e-mail: users-help@tortoisesvn.tigris.org
>
>
>

I've updated the script to work with Excel pre-2003 (see below). This is
similar to side-by-side comparison as it will horizontally tile two
workbooks. It is not the quite same because you have to scroll in both
workbooks.

I've noticed that this script and the original posted will sometimes show a
difference for cells that have not changed. I think this is related to a
cell spanning multiple rows using the "Merge and center" functionality.

Anybody know how to fix this?

Thanks,
Kipp

begin pre2003 Excel script:
dim objExcelApp, objArgs, objScript, objBaseDoc, objNewDoc

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

sBaseDoc = objArgs(0)
sNewDoc = objArgs(1)

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 objExcelApp = Wscript.CreateObject("Excel.Application")
If Err.Number <> 0 Then
   Wscript.Echo "You must have Excel installed to perform this operation."
   Wscript.Quit 1
End If

'Open base excel sheet
objExcelApp.Workbooks.Open sBaseDoc
'Open new excel sheet
objExcelApp.Workbooks.Open sNewDoc
'Show Excel window
objExcelApp.Visible = True
'Create a compare side by side view
objExcelApp.Application.WindowState = xlMaximized
objExcelApp.Windows.Arrange(-4128)

'Mark differences in sNewDoc red
objExcelApp.Workbooks(2).Sheets(1).Cells.FormatConditions.Delete
objExcelApp.Workbooks(1).Sheets(1).Copy
,objExcelApp.Workbooks(2).Sheets(objExcelApp.Workbooks(2).Sheets.Count)
objExcelApp.Workbooks(2).Sheets(objExcelApp.Workbooks(2).Sheets.Count).Name
= "Dummy_for_Comparison"
objExcelApp.Workbooks(2).Sheets(1).Activate
'To create a local formula the cell A1 is used
original_content = objExcelApp.Workbooks(2).Sheets(1).Cells(1,1).Formula
String sFormula
objExcelApp.Workbooks(2).Sheets(1).Cells(1,1).Formula =
"=INDIRECT(""Dummy_for_Comparison" & "!""&ADDRESS(ROW(),COLUMN()))"
sFormula = objExcelApp.Workbooks(2).Sheets(1).Cells(1,1).FormulaLocal
objExcelApp.Workbooks(2).Sheets(1).Cells(1,1).Formula = original_content
'with the local formula the conditional formatting is used to mark the cells
that are different
const xlCellValue = 1
const xlNotEqual = 4
objExcelApp.Workbooks(2).Sheets(1).Cells.FormatConditions.Add xlCellValue,
xlNotEqual, sFormula
objExcelApp.Workbooks(2).Sheets(1).Cells.FormatConditions(1).Interior.ColorIndex
= 3

end pre2003 Excel script

-- 
View this message in context: http://www.nabble.com/Excel-diff-script-%28extended-version%29-tf3647535.html#a10858859
Sent from the tortoisesvn - users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: users-help@tortoisesvn.tigris.org
Received on Tue May 29 19:36:54 2007

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.