Looping with "Write Cell" activity


I am writing a cell to an excel sheet at each iteration of a loop. When i use the write cell without the “Excel application scope” I get the following error message “Write cell : The process cannot access the file because it is being used by another process.” How can I solve this issue?

I am aware that a workaround is to use the “Excel application scope”, but this is highly ineffective and slows down the loop. I would like the process to be done in the background.

Hi @slekve

There are two ways you can work on excel first is with Excel Application Scope


Another is workboook activity


If they both are failing then there must be some instance left opened in process you will need to kill process manually or if you want you can use Kill Process activity and Kill Excel process


This might also help with some more insight.

This may be due to it is opening the excel file for each iteration and file opened in the prev iteration is still open. So Application scope is the best option.

Thank you for the quick replies, everybody. For the record I am aware that using excel application scope works for what I am trying to achieve. The problem is that I am for each iteration of the loop excel is opened and closed in the foreground which makes the process incredibly slow. This is why I am trying to make the workbook approach work. It is much faster.

I suspect that the in some way the previous iteration in the loop is interfereing with the current iteration. Is there some kind of “Delay” or “Wait for …” I can use?

By the way the activity that causes the issue is the “write cell” activity in this “Transpose” workflow:

PS: The error message is displayed the majority of the times i am running the workflow, but not every time.

You could test if it’s a delay issue by changing the “Delay after” property in your final loop step to a high value. Perhaps if you try this, and set it at 30 seconds (remember the value is in ms so adjust up) just to be sure and see if it still creates the error message? If so we can consider working on creating a delay, otherwise it might be something else which will require looking at.