How to check whether Excel file is already opened or not

I want to check whether my Macro file is already opened or not.
The process flow is if Excel Macro file Not opened in background then need to download that from web browser or else if it is already open then skip download workflow and proceed with already opened one.

For that I used .Visible activity in Flow Decision but it is not working.


Below is the Argument which I declared to stored the macro which I opened first time and as per this Argument I want to check next time whether it is already opened or not.


Hy @nilesh.mahajan

The best practices in Uipath suggest you close all excel files prior running your bot. There is the kill activity that does that. Make sure all files are closed prior to your bot runs, ok?

@nilesh.mahajan please have a look
How to check if any Excel file is open? - #2 by ClaytonM

@nilesh.mahajan - do you want to see if the robot has it opened, or if any user has it opened?

To see if the robot has it opened, you should be saving it as a Workbook variable anytime you have the robot open the excel file. Then you can see if it’s opened by checking if that workbook variable is null or not. This can be done by checking YourWorkbookVariable is Nothing - if true, then it’s not opened. If false then it is open.

To see if anyone has it opened, then go with the method in the link posted by @Arpit_Kesharwani. I would suggest just using the workbook read range activity surrounded in a try-catch. The catch portion should catch System.IO.IOException - if this type of error is caught then that means the workbook is currently opened by someone and you can handle it however you’d like.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.