Forum Discussion

msap's avatar
msap
Frequent Contributor
7 years ago
Solved

compare Excel files:

Hi    Getting an error "  Cannot read property 'ExcelCompare' of undefined Error location: The below script I copied from the smartbear testcomplete article. When I  am trying to compare two  exc...
  • tristaanogre's avatar
    7 years ago

    If this is the article (https://support.smartbear.com/viewarticle/42199/)

     

    then change your code to

    function Main()
    {
    
    xlfile1 = "C:\\excel1.xlsm";
    xlfile2 = "C:\\excel2.xlsm";
    resfile = "C:\\excel3.xlsm";
    Log.Message(objectExcel.ExcelCompare(xlfile1,xlfile2,resfile));
    }

    Note several changes

     

    1) Removed the variable declaration.  That is probably the main cause of your problem.

    2) Added the extra backslash to the file paths. JavaScript uses the backslash as an "escape" character so to actually send a backslash, you need to double it up.

    3) Wrapped the extension call in a Log.Message so you actually get an output.

     

    Basically... I recreated the actual script code that was in the article with the only exception being that I'm actually using real paths.  Please try the above code and see if that works.