Ask a Question

Not able to open excel from test complete

SOLVED
Preetha
Occasional Contributor

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

1 ACCEPTED SOLUTION

Accepted Solutions
Preetha
Occasional Contributor

Re: Not able to open excel from test complete

used Project variable it is working fine Thanks

View solution in original post

2 REPLIES 2
Wamboo
Community Hero

Re: Not able to open excel from test complete

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
Occasional Contributor

Re: Not able to open excel from test complete

used Project variable it is working fine Thanks

View solution in original post

cancel
Showing results for 
Search instead for 
Did you mean: