Forum Discussion
So, you are calling xfile1.Cells.... but xlfile1 is a string... there is not a "Cells" function on that object.
What you need to do is declare another variable to contain the workbook object. Something like
let xlWorkbook1 = Excel.Workbooks.Open(xlfile1)
let xlWorkbook2 = Excel.Workbooks.Open(xlfile2)
Then you would call
if (xlWorkbook1.Cells(i,1).Value === xlWorkbook2.Cells(i,1).Value) {
Log.Message("The files are the same.");
}};
- Ivett_K4 years agoOccasional Contributor
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
- tristaanogre4 years agoEsteemed Contributor
It MIGHT be due to this.
https://support.smartbear.com/testcomplete/docs/scripting/specifics/javascript.html#indexedprops
- sonya_m4 years agoSmartBear Alumni (Retired)
Thank you for helping tristaanogre
Ivett_K , did you manage to solve this issue?
If you update to the latest TestComplete version (14.50), you can try using the new Excel support to implement this task. It does not even require Excel to be installed on the machine.
Related Content
- 9 months agoLuukdb
- 9 years agoilovechiku
Recent Discussions
- 25 minutes agomarkos