Excel is not in Ready state error when processing multiple files

Hi,

I’m getting the following error when processing multiple Excel files in my automation:

“Use Excel File: Excel is not in Ready state. Please make sure you are not editing any cells and that no dialog windows are opened.”

My process looks like this:

  1. Read data with Workbook Read Range.
  2. Modify a DataTable in memory.
  3. Write data back with Write DataTable to Excel inside a Use Excel File and Excel process scope (to preserve formatting).
  4. Check if the file is locked → if so, delay by 5 sec. and retry “is file locked-scope”.

This works for the first file, but when the next transaction starts, I get the “Excel not in Ready state” error.

It all works just fine when running from studio, but as soon as I’m testing from my Orchestrator Test Tenant it fails.

I’ve tried multiple solitions like using Kill Process (EXCEL) if the file is locked (both before using the Use Excel File activity and in the “Check if the file is locked-loop”), using only workbook activities (but this kills the data formatting when writing back to excel, and I need the data to be in the same format as the original file).

Additional information: I’m using Integration Service activities to download the file from SharePoint and then manipulate data locally before uploading the file to SharePoint again. Optimally I would just edit directly in the SharePoint file, but it doesn’t work either.

I hope some of you have a solution for my problem. I’ve talked a lot to ChatGPT about this, but nothing really works stabily.
Does anyone know the best practice to safely handle multiple files while keeping the Excel formatting when editing data and writing back to the file?

Thanks in advance!

run a kill Excel process before each file is loaded, Excel like to leave background processes running sometimes whihc makes UiPath think its being used for something else

Hi @Kristine_BH

in the start of flow try using the Kill Process (EXCEL) and see this helps

Cheers

Hi @Kristine_BH ,
Enable on the Force Kill option under the Existing Processes Action property in the Excel Process Scope, and try again. I believe this will resolve the issue without needing any additional UiPath activities.

Unfortunately it still doesn’t work. I’ve tried using Kill process (Excel) both before the Excel Process Scope and after, but still getting the errors.

This error typically indicates that there is an Excel file open and the cursor is in the field edit box - like when you click a field and put the cursor into that box at the top where you enter formulas etc.

1 Like

Kill process is a bad idea. It’s blunt hammer, and rarely necessary. It can corrupt Excel files and cause many issues.

1 Like

Kill Process is way overused. It’s blunt hammer and if things are done correctly isn’t necessary.

1 Like

@postwick thank you for your information. As i don’t use Kill process often maybe you are right about it.

  • In my project i use close application activity (timeout property value = 3sec) as an initial task and it’s running fine without causing issue to Excel app, SAP and Chrome browser in our production server from past 3 years. @Kristine_BH maybe you can try the same.
  • Also instead of workbook activities, try to use the use excel file activity and inside it keep the read range activity.
  • Keep the step 3 as it is. if still shows error then try with workbook Write Range activity

PS: in close application activity selector only keep <wnd app ='excel.exe'/>

Do these steps and let us know your result.

Happy Automation!

Have you tested each file independently as the first file to confirm each one works as expected? I ask because we have encountered issues with a batch of Excel files later find out there was something wrong with the file itself.

Also I want to confirm the error message only appears during the “write” process, or does it appear when attempting to read the file?

1 Like

I second the approach of implementing the Use Excel File activity for reading and writing.

We can follow your approach by using sing Use Excel activity.
However, I suggested using separate Use Excel File activities for Read Range and Write Range activities, so that we can see if there is any issue with either of them.

The files works just fine, tried with several different files - just looks like excel isn’t closed correctly after using the first file, and that’s why it’s failing with the next file.

Correct, I get the “Excel not in ready state” when trying to write to the file, but I’ve also gotten the “The process cannot access the file ‘xxx.xlsx’ because it is being used by another process” when trying to read the file.

Thanks for the detailed answer.
I’ve tried your suggestion, but now I’m getting the error: Read Range: Could not read range A:XFD.

I’ve managed to get it to work by using only workbook activities and only replacing data in one column which is not that dependent on keeping the format. But my colleague will probably face the same issue soon, since he’s even more dependent on the data format.