Append range - how to ensure the file is not used by another process

Hi
In my workflow I update the Excel file by Append range activity.
Quite often I get this error:
Append Range: The process cannot access the file MyDataTable.xlsx’ because it is being used by another process.
Is there a way to pause the workflow until the file is “released” ?

Hi,

You can actually introduce a delay activity to pause the workflow for some amount of time. But, it is not a good practice because we don’t know how long it will take for the file to be free to use by the workflow. The best way to deal with that situation is to introduce a try catch activity. and place your Append Range within the Try segment. Catch the System.IO Exception or System.Exception. If the exception is caught, you may send a alert, or get some log records created, or may be retry…

1 Like

Thank you @Lahiru.Fernando
I think Try /Catch is the best option. The best way is to retry in my case. I also introduce a small delay in the catch section.

1 Like

Hi,

The append range creates a new file if the current one is being used by someone or is in read-only mode. How do we check that before hand

@Sneha2
Use Kil process activity before the excel process, It will kill the entire excel process.
image

The file may not be open by a process on the local machine. Could be someone from another computer has it open.

You can’t really pause until it’s released, but you can use a Retry Scope to keep trying to write to the file a certain number of times with a specified delay between tries. It won’t retry if the Append Range is successful. If the tries are used up and it still can’t write, then Retry Scope throws an error.

1 Like