Forum Discussion

Ivett_K's avatar
Ivett_K
Occasional Contributor
5 years ago

Re: How to compare two Excel workbook's cell values

Hi Robert,

 

Thank you for your quick reply. I changed the code to this:

 

function CompareExcel()
{
let Excel = getActiveXObject("Excel.Application");

let xlfile1 = "S:\\Software\\mytilney.xlsx";
let xlfile2 = "S:\\Software\\plan.xlsx";

let RowCount = Excel.ActiveSheet.UsedRange.Rows.Count;

let xlWorkbook1 = Excel.Workbooks.Open(xlfile1);
let xlWorkbook2 = Excel.Workbooks.Open(xlfile2);


for (let i = 1; i <= RowCount; i++) {

if (xlWorkbook1.Cells(i,1).Value === xlWorkbook2.Cells(i,1).Value) {
Log.Message("The files are the same."); }
};

Excel.Quit();
}

 

But when I run it I'm still getting the same error:

 

'TypeError: xlWorkbook1.Cells is not a function' 

 

Thanks,

 

Ivett

3 Replies