Forum Discussion

Preetha's avatar
Preetha
Occasional Contributor
6 years ago

Not able to open excel from test complete

getting the below error 

sorry we couldn't find C:\QA\PATCAT\PATCAT_suite\PATCAT\Results\CATRegressionCompareTestResults.xlsx. Is it possible it was moved, renamed or deleted?

 

I can see the excel in the same path.

 

This is my code


resultToExcel.rowNo= 2; //static variable

function resultToExcel(Apptn,graphname,count)
{
var rowNo;
var fileName=Project.ConfigPath+"\Result\\CATRegressionCompareTestResults.xlsx";

 var excel = Sys.OleObject("Excel.Application");

var myWorkbook = excel.Workbooks.Open(fileName); //// this line is giving the error
var mySheet = myWorkBook.Sheets.Item("Sheet1");


excel.Cells.Item(rowNo,2).Value=graphname;

if(Apptn="PAT")
{
excel.Cells.Item(rowNo,3).Value=count;
}
else if(Apptn="CAT")
{
excel.Cells.Item(rowNo,4).Value=count;
}

myWorkBook.Save();
excel.Quit();
}

 

 

Please let me know if i am doing anything wrong

  • used Project variable it is working fine Thanks

  • Wamboo's avatar
    Wamboo
    Community Hero

    Hi

     

    let trash = Project.ConfigPath; -> it is ending with double slashes.

     

    For example:

     

    "C:\\Users\\UserName\\Docs\\TestComplete 14 Projects\\ProjectSuiteName\\ProjectName\\name\\"

     

    in this line:

     

    var fileName=Project.ConfigPath+"\Result\\CATRegressionCompareTestResults.xlsx";

     

    Remove one backslash at the beginning. Try to remove it, becouse in my opinion you don't need it.

     

    Also you can use Project.Path variable as well.

    • Preetha's avatar
      Preetha
      Occasional Contributor

      used Project variable it is working fine Thanks