cancel
Showing results for 
Search instead for 
Did you mean: 

Excel file in use

BenAnderson
Level 5
Hi,    I was wondering if it is possible to ascertain if an excel is being used by another process. For example, if one process and one resource are using the file, then a different process and resource would presumably throw an error when trying to access the same file.    Is there any functionality within BP to allow the process to check to see if the file is currently open or being used?   Many thanks,    B
Benjamin Anderson, Senior Consultant, UK
4 REPLIES 4

Deep.Shah
Level 6
One way is to use Blue Prism's Environment Locks to control access to shared resources like a file in your case.

BenAnderson
Level 5
Hi Deep.Shah,    Thanks for your reply. If I was to use a lock, would that be visible across all processes. or are locks process specific? So for example, if two different processes are trying to access the same excel file, one process can access it because it has the lock, but the other process can't?    Many thanks in advance,   B
Benjamin Anderson, Senior Consultant, UK

david.l.morris
Level 15
To answer your question, yes, the lock is visible to all processes. Environment Locks are visible across the entire Blue Prism environment so any runtime resource running any process can check for a specific Environment Lock. But I'd caution you that if you haven't used them before, you should go ahead and do some thorough testing to understand that feature. The first thing you will notice is that it does not actually lock anything except an arbitrary piece of text in the Environment Locks section of the System tab in Blue Prism. Only processes that adhere to the 'contract' of acquiring the lock will be beholden to the rule of only one resource accessing the file at a time. Also, one thing I've done sometimes as a secondary measure to determine if an Excel file is currently in use is to use the 'File Exists' action looking for the file but with the characters ~$ at the beginning. When Excel becomes locked, a lock file is created in the same folder that is prepended with those two characters. If the file exists, then the process would know not to try opening it.

Dave Morris, 3Ci at Southern Company

BenAnderson
Level 5
Hi David,    Many thanks for your response. Your secondary measure is very clever, and is exactly the kind of thing I was looking for. I'll spend some time looking at and testing both options.    Thank you again,    Ben
Benjamin Anderson, Senior Consultant, UK