My program deals with lots of Excel files, and keeps opening and closing them during the course of the execution. Before the user can run this robot, I want to give them a warning saying they need to close all Excel files if there is an Excel file, or more than Excel files that are open.
But I am not sure how to make the robot detect an open Excel file. I don’t want this warning to be displayed if there is no Excel file that is currently open.
I am using the following logic, but this doesn’t always work.
Get Processes Activity:
– Output: allProcesses
For Each Activity:
– For Each process in allProcesses
—> if process.ToString.Contains(“Excel”) or process.ToString.Contains(“EXCEL”)
---------> Message Box Activity: “Please close Excel programs.”
---------> Break Activity:
This works when there is actually an open Excel workbook. But sometimes, even though there is no Excel file open, it still displays the message. I checked the task manager, and there was an Excel process even though no Excel file was actually open.
How can I modify this logic to make it work 100%?
Note: I don’t want to use “Kill Process”. I would rather warn the user and let them choose to close the application.