Getting an error about "because it is being used by another process" error

hi, i am trying to build a job as per the course “Build your first process with studio”. but seem there is an error throwing out when the job trying to attach the updated excel to the email as draft. error shown below, it seems the Microsoft excel is not still processing at the backend even the excel files are all closed, i tried to add a timer or something to delay the attaching in gmail task run but seem still not working,wonder if there is anything i can do to solve the issue.

thanks a lot in advance!

Hi @sinkt88 ,

Refer to the below thread:

@sinkt88 can you upload the process xaml here

Hi @sinkt88
Here is two possible scenarios to avoid this error.
One is kill process activity ( but i don’t recommend it untill unless you put script to kill only your user processes.

Second is make a copy of your excel and send/use it where you want to use it.

Happy automation

Hi @sinkt88, you can use Kill Process and pass ‘excel’ in it to kill excel process. Sometimes we do not see excel open or it’s process in task manager but still it’s instance is active in systems memory which cause this issue.


Please use a kill process …before sending email to make sure the excel is completey closed


Not sure if i understand the kill process,is there any way i could add a process before i initiate the gmail running process,attaching my xaml file here for reference.
I have also tried to replace the write cell function under classic to Write cell workbook under “WorkBook” but seems i am getting the empty extension error, not sure how should i select the path with it

Main - Copy.xaml (83.2 KB)

@sinkt88 Hi,
How can I help you. can you share what error is coming. I am not able to open your code.

Thanks Raja,
I tried one of the solution provided above eg adding a kill process after the excel is being amended but looks like the kill process didnt work and it’s just continuing the gmail generating email task and popping the same error excel is being used by another process

@sinkt88 put “excel” in process space bar.

try like this.
its working for my case.
processname → means that which processes you want to kill. It can be excel, explorer, chrome

Thanks Raja, it’s working now sir!

  1. But i am curious how the kill process able to recognise the excel application when i just type “Excel” in the ProcessName? is excel some sort of default variable in UiPath?
  2. Looks like after the kill process function working eg attaching the excel file in the email but then the excel job still running to process the rest of the excel, i got four excel want to process in total but it attached one file to an email and then generating a second email with two attachments and then third email with three attachments with it…etc. Looks like the kill process can suppress the excel update function temporarily so that it goes to the email generation function but i was thinking if i should add a timer or something that allow the whole excel sheet amendment function run till the end and then kill process and then to email generation process?
  3. Wonder which function should i add to clean up the folder that storing the excel attachment before i generate the email so that i wont including duplicated excel as attachment?

thx a lot

1)if you want to find the name needed to use in the killing process please go to the file location of the application and check the properties.we do not want to specify .exe

  1. Try to add a kill process before the start of the process to get a clean environment for running the bot. Kill process is just like killing the process in the task manager. if you are using excel application scope there is no problem if excel is already running.
  2. For cleaning the files inside the folder you can use Directory.Getfiles(FolderLocation). please check videos related to it.

Happy Learning