Comparing Excel files using code

You can go further in automating the process of Comparing Excel files because 4TOPS Compare Excel Files is an ActiveX program. By pressing the [Macro]-button you get the code which matches the current settings and a short instructions how to include the code in your Visual Basic or Office (VBA, Excel, Access) application.

Example code obtained using the [Macro]-button

'This macro code can be called from your Visual Basic or Office (VBA, Excel, Access) application.
'This way you can use the ExcelCompare program as an Excel Comparison server / library to
'integrate comparison with your program's process.
'1. New or Open module in your application
'2. Past this code into the module
'3. Set a reference to xlcompare.exe

Sub ExcelCompare1()
    Dim Success As xlCompare.ecResult
    Dim oXlCompare As xlCompare.Compare

    Set oXlCompare = New xlCompare.Compare
    Success = oXlCompare.Execute(File1:="C:\projects\agora\VB6\code\ExcelCompare\TestFiles\FileNew.xls", _
            File2:="C:\projects\agora\VB6\code\ExcelCompare\TestFiles\FilePreviousDiffRowOrder.xls", _
            Worksheet1:="SheetWithTable", _
            Worksheet2:="SheetWithTable", _
            StartRow:=1, _
            IdentifyingColumns:="1", _
            StartColumn:="1", _
            EndColumn:="77", _
            PrintTo:="C:\projects\agora\VB6\code\ExcelCompare\Reports\compare tables analysis.htm", _
            OpenReport:=True, _
            PrintVisualizedTo:="C:\projects\agora\VB6\code\ExcelCompare\Reports\compare tables visualisation.htm", _
    Select Case Success
    Case ecResultNormal
        MsgBox "Comparison is finished successfully.", vbInformation
    Case ecResultEqual
        MsgBox "No different.", vbInformation
    Case ecResultCancel
        MsgBox "Comparison is canceled.", vbInformation
    Case ecResultError
        MsgBox "Error during execution of comparison.", vbCritical
    End Select
    Set oXlCompare = Nothing
End Sub

Tutorials on comparing spreadsheets