Forum Discussion
I am explaining you the problem with the following example:
function test()
{
code1.................
.......................
ExcelComp("C:\\Bur319.xls","C:\\myfiles\\PDF\\Burster\\Bur319.xls"); //It fails when it does not find the excel file for comparison
..........................
..........................
code1
}
ExcelComp is a separate function where it calls another function createinfo()
function createInfo(oExcel, fileName, aSheets)
createInfo(oExcel, fileName, aSheets)
{
var oSheets;
oExcel.Workbooks.Close();
oExcel.Workbooks.Open(fileName); //Exception occurs at this point when it tries to find a non-existing excel file
oSheets = oExcel.Worksheets;
sheetCount = oSheets.Count;
......................................
//code
}
So I tried to use this code of try-catch and modifed createInfo function as but after logging the exception after catch block -I want to avoid going through rest of the code in createInfo() and go back again to the function test().How can I do that?
function createInfo(oExcel, fileName, aSheets)
{
var oSheets;
oExcel.Workbooks.Close();
try{
oExcel.Workbooks.Open(fileName); //Exception occurs at this point when it tries to find a non-existing excel file
}
catch(e)
{Log.Error("Exception occured",e.description);}
oSheets = oExcel.Worksheets;
sheetCount = oSheets.Count;
......................................
//code
}
Thanks,
Sumedha