I am trying to read from excel file, getting runtime execution error that file is being used by another process

20.10.4+Branch.master.Sha.6a6cfd6dfbeb86aec47564af2f9465ef0bf43df4

Source: Read Cell

Message: The process cannot access the file ‘C:\Users\sampada\Documents\sampada.xlsx’ because it is being used by another process.

Exception Type: System.IO.IOException

RemoteException wrapping System.IO.IOException: The process cannot access the file ‘C:\Users\sampada\Documents\sampada.xlsx’ because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at MS.Internal.IO.Zip.ZipArchive.OpenOnFile(String path, FileMode mode, FileAccess access, FileShare share, Boolean streaming)
at System.IO.Packaging.ZipPackage…ctor(String path, FileMode mode, FileAccess access, FileShare share, Boolean streaming)
at System.IO.Packaging.Package.Open(String path, FileMode packageMode, FileAccess packageAccess, FileShare packageShare, Boolean streaming)
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.OpenCore(String path, Boolean readWriteMode)
at DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(String path, Boolean isEditable, OpenSettings openSettings)
at ClosedXML.Excel.XLWorkbook.LoadSheets(String fileName) in C:\Projects\ClosedXML\ClosedXML\Excel\XLWorkbook_Load.cs:line 44
at UiPath.Excel.WorkbookFile…ctor(String workbookPath, String password, Boolean createNew)
at UiPath.Excel.Activities.WorkbookActivity1.ConstructWorkbook(String path, String password, Boolean createNew) at UiPath.Excel.Activities.WorkbookActivity1.BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, Object state)
at System.Activities.AsyncCodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Hi @Sampada_Atre,
Is the excel file closed when you run the automation?

Yes… Excel is closed while running program…

@Sampada_Atre

As your file is xlsx, try to use Excel workbook activities

image

Let us know if you still get the same issue

Hope this helps you

Thanks

I know I’m asking trivial questions but sometimes it happens that somebody will forgot about simple things so sorry for that :slight_smile:

Anyway… if you will have this message (just my curiosity) please check if there is no excel process in the background at the same time.

Tried to do with as u suggested… Still it’s not working… Thanks a lot.

Nope… Not working…
Thnkx a lot.

Hii,
No excel is running, not a single excel is open.

@Sampada_Atre

Can you try with other excel file, and check if the same error you are encountering

Thanks

Hi Sampada_Atre

Use kill process before Excel application scope

In Kill process give the process Name as “EXCEL”

Thanks

Tried it… It’s not working yet…

Thnkx.

I tried with new fresh execel in new bot… It worked only once… Then again it started giving same error…
Thnkx.