Excel remaining open after closing application scope

I have a robot that downloads an xls file from a web site. It then opens it with Excel application in order to apply some reformatting. The excel actions are executed inside an Excel Application Scope.
According to documentation and if I’m not wrong, the Excel files are closed when the application scope activity ends. Unfortunately this does not happen every time: there are times when the XLS remain open even after the robot has ended. This problem is more frequent when I run the robot from the Robot Tray rather than from Studio.

I also tried to specify a WorkbookApplication variable, then to explicitly call CloseWorkbook at the end, with no success.

Is there a safe and deterministic way to close Excel at the end of an Application Scope ?


Close workbook needs to be OUTSIDE of the excel application scope.

I’ve also noticed that sometimes it needs to have a few extra milliseconds between the end of the excel scope and the close workbook activity for it to workproperly. Just put in a write line activity or a super short delay activity in between if needed.

OK I moved CloseWorkbook outside of the excel scope, and I added a short delay as suggested.
It’s not working in the following scenario:

unattended robot, run by UiRobot, in an RDP session, saving files to a network mounted folder

Could the excel scope / CloseWorkbook have closing issues when saving to remote folders ?

Hi there @prepetti

Have you tried to uncheck the visible property?

1 Like

Yeah, thist can be done, if @prepetti you want all the operations to done in the BG!

Hi all,
thanks for your suggestions.

If I uncheck the visible property should I also check the simulateClick/sendWindowMessage on every interaction with Excel ?

Your workflow would work without that! :smiley:

I’m afraid not.

I had to find a different way: I save the file to a local temp folder, then I close the Excel scope, then I move the file to the network folder. This appears to work in all conditions (both attended and unattended).

Thanks all the same.


Iam facing the same issue,even if iam using close workbook activity outside of the excel application scope.

But same is working if the excel scope is not in a big flow.