Try / Catch on locked Excel without killing the process


I want to move an excel file but I have the following error “Move File: The process cannot access the file because it is being used by another process.”.

So, I don’t want to kill the process because the file owner is working on it…
I just want the robot moves available files (unlocked files by excel process).

How to do that without killing the process ?
try/catch seems not working on it…

Thanks in advance.

I have a couple questions about your process

Are you moving many files or this one specific file?
Is the file located in a shared folder/location?
Have you done any work on this file in the program, is the file opened on your pc when you try to move it?

One thing to remember is that when running in debug mode the program will still get hung up on try catch loops and you as the user must hit continue until the program fails completely and ends or the workflow continues. If you want to see what the workflow will do in a more realistic situation, select the Run in the dropdown list below debug.

Hello JosephNehl,

I try to move many files located on a specific shared directory.
Some time a specific file is locked by his owner.
In this case, the Try/Catch failes.

I my case, the robot must be autonomous.

Any idea ?

Thanks in advance…

Hi @jean-christophe.calviera
are you using this move file activity within the for loop?

This sequence is in a For Each (files) Loop.

ok, then assign the try-catch block within the for each loop, and in the catch block use continue activity

It will skip that file which is opened and will execute for the next file to move

The continue activity is in the Catches block but the Robot stop before this activity…

May be the Try/Catch activity is misused?

Maybe a stupid question, but could it be the case that you are in “Debugging-Mode”? In this case the robot stops on move-file, but when you click on “Continue” it will jump to the catch-block.


A question is never stupid!
A response, sometime…

I was in “Debug-Mode”…
@all Tank you very much !

1 Like