Ask a Question

how to open excel file using TestComplete


how to open excel file using TestComplete


I am not able to open excel file using this methd , though its is getting passed but required action is not taking place

function ExcelExample()

// Get the sheet of the Excel file
var excelFile = Excel.Open("C:\\Users\\Public\\TestInput\\ChartInput.xlsx");
var excelSheet = excelFile.SheetByTitle("Sheet1");



Champion Level 2

What is happening when you try this?


@Marsha_R  No action is taking place , script just got passed thats it.

Your syntax is correct, so I would first look for an issue with file permissions. Make sure that TestComplete has access to that particular directory. You could try putting the Excel file on the desktop to begin with, just to confirm the permissions.



No action is taking place

What action do you expect?

Note, that Excel object provided by TestComplete does not require Excel application to be installed and thus does not provide any UI.

If you need to open the file in Excel application, then you must start Excel as a COM object and use its object model. ( as an example)


  /Alex [Community Champion]
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.

@Marsha_R  I have tried this but no result , script got passed but no required action took place


I have tried this two methods and script got passed but required excel file didnt get open 


function ReadDataFromExcel()
let Excel1 = Sys.OleObject("Excel.Application");




function ReadDataFromExcel()
let Excel = getActiveXObject("Excel.Application");



Hi @Jainsoumya!


No action is taking place, because there is no action to perform in the code sample.


In the small sample above, TestComplete is simply opening and closing the sheet in the background.


Since there is no other action, such a Log event to post results, nothing is being returned. 


Is there another action further down in your code that is not working? If you are only running the snippet provided, then no results in your logs is going to be the expected result.


Solutions Engineer @ SmartBear

@npaisley  so what is the code to open the required excel file ?

You have the correct code to open the file but what @npaisley is saying is the open does not count as an action for TestComplete so it does not log it.  The file has been opened  in the background and nothing is visible. Same for the sheet reference.  You set it to a variable but this is not a logged action.


Try doing something next like getting a value from the sheet and putting it in a log message. That will show an action.

Showing results for 
Search instead for 
Did you mean: