The process cannot access the file because it is being used by another process

excel
activities
p_known
p_doc

#1

Hello,
I was trying to implement an example with Excel triggers. However, every time Excel file is modified and saved UIPath throws an exception:

Monitor_Excel has thrown an exception

Message: The process cannot access the file ‘[local path]\invoice-template.xlsx’ because it is being used by another process.

Source: Read total value

Exception Type: IOException

System.IO.IOException: The process cannot access the file ‘[local path]\invoice-template.xlsx’ because it is being used by another process.
at UiPath.Core.Activities.MonitorEvents.BodyFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Any ideas what causes this?..


Error: The process cannot access the file because it is being used by another process
Delete Activity Error
#2

hi Elvis

the attached workflow has 2 validation errors, some lost space characters in two activities.
you will notice them when validating using the Studio`s option. If you fix those, the workflow will run just fine.
make sure you have excel package installed.


#3

@Elvis

Usually it will come when you have opened that Excel which have written in WriteRange …

Plz add that xaml to identify the error…


#4

File change.zip (16.5 KB)

Hello,
thank you for the reply. I’ve attached all files. Any ideas on how to solve this?..


#5

Calling below in your finally block of try catch method might help resolve the issue, unless you are missing something in the code.


#6

Thank you for the reply, but this didn’t help. The file still can’t be accessed:

Monitor_Excel has thrown an exception

Message: The process cannot access the file ‘C:\Users\user\Documents\UiPath\File change\invoice-template.xlsx’ because it is being used by another process.

Source: Private: Read total value

Exception Type: IOException

System.IO.IOException: The process cannot access the file ‘C:\Users\user\Documents\UiPath\File change\invoice-template.xlsx’ because it is being used by another process.
at UiPath.Core.Activities.MonitorEvents.BodyFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)


#7

Please share your xaml.


#8

Please check the message above, I’ve put all files in .zip archive.


#9

I have modified the code, can you try and let me know if it works.

File change.zip (17.2 KB)


The process cannot access the file 'PATH' because it is being used by another process
#10

Hello and thank you for your inquiry.

first of all I guess you need to redefine the process because you are trying to get information from an excel template while it’s being process…(obviiously the reason for the error XD)

So, I see two approcheas here, one is to save the workbook and continue or to ask the user to close it. Like I said you need to define your automation in the way that will achieve what your customer wants to achieve.

For the ones intriguing about System.GC this and this article might be helpful

and here it’s the XAML xlalreadyopen.zip (51.2 KB)

:slight_smile:


#11

I have kept a while loop where the robot keeps checking until the error has vanished ( you can send alert here) and in finally used GC method which I assume should work for him.

Refer my code if you want to.


#12

@vvaidya Awesome, I like your approach for this automation. keep up!!! :sunglasses:


#13

Works perfectly, thank you very much!
I believe someone should ping UIPath to update their knowledge base article on Excel triggers with your solution.

Thank you once more for your help!


#14

@docteam