Hello, I’m just starting to learn how to use this tool and I’m following along with an example from a video tutorial. The example involves generating an Excel file in one folder, adding headers to it, and then reading all the Excel files in another folder within the same project and copying their content into the one I created. The first part works fine, but when it comes to saving the content, I encounter an error. I want to clarify that no other application is currently using the file, and it’s not from a different version.
this is the error
24.2.0-beta.15927+Branch.release-v24.2.0.Sha.362a7780a0c4f2f55d19fe4a09b64116ac9b31a7.362a7780a0c4f2f55d19fe4a09b64116ac9b31a7
Source: Use Excel File
Message: Failed opening the Excel file C:\Users\priva\OneDrive\Documentos\UiPath\Excel report consolidatios\Sales Results~$SalesResults-2024-02-21.xlsx. Possible reasons: the file is corrupt, the file is already used by another process or you don’t have permissions to open the file.
Exception Type: UiPath.Excel.ExcelException
UiPath.Excel.ExcelException: Failed opening the Excel file C:\Users\priva\OneDrive\Documentos\UiPath\Excel report consolidatios\Sales Results~$SalesResults-2024-02-21.xlsx. Possible reasons: the file is corrupt, the file is already used by another process or you don’t have permissions to open the file. —> System.Runtime.InteropServices.COMException: Excel no puede abrir el archivo ‘~$SalesResults-2024-02-21.xlsx’ porque el formato o la extensión no son válidos. Compruebe que el archivo no se ha dañado y que la extensión y el formato del archivo coinciden. at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
at UiPath.Excel.WorkbookApplication.InitializeCurrentWorkbook(WorkbookArguments workbookArguments, Workbooks workbooks)
at UiPath.Excel.WorkbookApplication.InternalOpenWorkbook(WorkbookArguments args, Boolean onlyIfWorkbookExists)
— End of inner exception stack trace —
at UiPath.Excel.WorkbookApplication.InternalOpenWorkbook(WorkbookArguments args, Boolean onlyIfWorkbookExists)
at UiPath.Excel.ExtendedWorkbookFactory.Create(Boolean attachOnly)
at UiPath.Excel.WorkbookQuickHandle.SafeGetWorkbook(Boolean attachOnly)
at UiPath.Excel.WorkbookQuickHandle.OpenWorkbook()
at UiPath.Excel.Activities.Business.ExcelApplicationCard.InitializeQuickHandle(RuntimeLoggingService runtimeLogging, IWorkbookQuickHandle workbookQuickHandle, IExcelProcess excelProcess, WorkbookDefaultOptions workbookDefaultOptions, String path, String password, String editPassword, Boolean createIfNotExist, Boolean keepExcelOpen, Nullable`1 readFormatting, Boolean readOnly, ResizeWindowOptions resizeWindow, Boolean saveChanges)
at UiPath.Excel.Activities.Business.ExcelApplicationCard.Execute(NativeActivityContext context)
at System.Activities.NativeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Hi,
It seems robot try to read temp file.
Do you use ForEachFileInFodler activity? If so, can you try to add the following IF and Continue activity to skip temp file at the beginning of loop block?
CurrentFile.Name.StartsWith("~")
Regards,
Thank you very much for your response. I tried what you suggested but it didn’t work, it’s still throwing the same error. Could it be that because it’s open from the moment it’s created, it’s being treated as if it’s being used by another process?
I was facing the same error. I disabled my OneDrive from task manager and it worked fine. You can check if that is the case for you as well.