Write Cell: The process cannot access the file ... because it is being used by another process / The semaphore timeout period has expired delay

Hi everyone,
I almost completed my first project. Main duties for this automation is to do some corss-check between the data contatined in 3-4 difrent excel files and then output the infomation about correctness/incorrectness of the data and the root that causes it. So, for now it consists of 7 modules which in almost each of them is the same logic(read ranges, for each row, look up data table, if condition, write a cell activity). It worked already perfectly but i came back to this project after 5 day’s and i have this error:

  • Write Cell: The process cannot access the file ‘C:…\ZonesLocation.xlsx’ because it is being used by another process.

I tried to input some delays after writting the cell activity because i thoguht it could be affected by the diffrence between execution time and processing time but, when i put the delays after this activity i received another, the same kind of errors in my project in the same kind of place(in write a cell activity). I put another delays. The duration got longer and i have received another, diffrent error:

  • The semaphore timeout period has expired delay.

I tried to shortage delays with this error but i received them in other(same kind) places. And in some cases it was the obstacle that i couldn’t effort.
So here’s my question’s:
What is the purpouse of the first part of my problem(,Cannot access file because using by other process") and what solution will fix this? (honestly i want to avoid the delays and longer time duration)
What is the purpouse and solution for second part of my problem(,the semaphore timeout period has expired delay")?
I want jut add, that i have had exactly the same error’s during developing it but i changed a bit logic and move two variables from “Global” scope to specific module and it fixed. But why it still happen? I didn’t changed anything.
I’m resigned already because i spent an hours on fixing this with no effect so i hope i will find any help here.
Below screenshots:





Can you ensure that the entire thing is contained within an excel scope? This will keep the file open until you say you wish for it to be closed. The error is popping up because you are closing/opening excel each time and that takes a long time, but the robot moves so fast that it tries to open it while the previous one is still closing, thus throwing the error.

I’d recommend using an excel activity scope and saving the output as an excel variable. Use this variable within all future write cell, write range, read range, etc activities. For your last excel activity, just mark the property in your excel activity scope to close the workbook, or use the ‘close workbook’ activity.

1 Like

Hi, thanks a lot for response. Good point, i belive it’s one of solution’s for this issue but, i want to understand what is the purpouse/rule for this error because, i restarted my computer, i implemented solution with excel application scope, it took a bit longer to proceed it all but it works and again, i changed my solution for the write a cell out of excel application scope just by workbook path and it works perfectly again. So, as I mentioned before, it’s a random issue that just happen randomly and I would like to really know the rule/issue why is it like that. I would like also to leave this solution in this way to make it work in the background and save duration time. In other hand i also belive that tomorrow i can wake up and see again the same error. Is it possible that it depends on my actual usage of memory? Or processor?
It strange because i was trying to restart my computer and run this automation on fresh computer without any additional porcesses in background and I also received the error.
Do you have any other solutions or ideas for this?
Thanks again lot for help and i hope for other ideas :slight_smile:

My proposal allows it to still work in the background and will be orders of magnitudes faster and more reliable.

If you write cell outside of application scope you need to wait for excel to initialize, load your program, make the change, save, and quit the application. It has to do this every single time you loop. This causes random errors because sometimes the system is able to do all that as fast, or faster, than the robot can function. However, there are random times where the robot works too fast and so the application hasn’t finished closing yet, thus throwing the error.

There is no reason for you to open/close the application every time you write to it. Instead, you open the application once, then write to it once, then close it once. Or if you absolutely have to use write cell each time, then it will still save a ton of time because it will open the application once, write to it n times, then close it once. Either way it avoids the error you are getting right now.

To make it run in the background, make sure the “visible” property of excel scope is NOT checked

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.