Use Excel File Issue


First of all i want to know, is it good practice to use combination of studio and studiox excel activities?. because i can able to find some activities in studiox for which i have used custom activities in earlier days of studio projects. Right now i’m using both studio and studiox excel activities in a single workflow. (Specifically used studiox activity for autofit range and formattting). I do get the following errors often, when i use USE EXCEL activity after EXCEL SCOPE activity.

System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at Microsoft.Office.Interop.Excel.ApplicationClass.get_Version()
at UiPath.Excel.Helpers.ExcelInteropHelpers.TryGetMajorVersion(Application excelApp, Int32& version)
at UiPath.Excel.ExtendedWorkbookApplication.ExtendedAttachOrCreateNew(WorkbookArguments workbookArguments, IExcelComAppManager comAppManager, ComAppOptions options, ExcelStartOptions excelStartOptions)
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.Execute(NativeActivityContext context)
at System.Activities.NativeActivity.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)
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at UiPath.Executor.BaseRunner.EndExecute(IAsyncResult result)
at UiPath.Executor.InProcessRunner.EndExecute(IAsyncResult result)
at UiPath.Core.Activities.ExecutorInvokeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

It sometime works and sometime doesn’t. I don’t find any answer from forum. Could anyone please give me an idea to this issue?

Note : I have tried by giving delay between two types of excel scope activities.and also tried to kill excel before using studiox excel activity and after using studio’s excel scope activity.

What does this mean? Are you using Excel Scope of Studio and then somewhere downstream using Excel scope from StudioX? If yes, did you consider the possibility that the first activity maybe locking the Excel document?

There is a Close Workbook activity you might want to use before you exit the Studio Excel Scope activity. That way you don’t have to kill Excel.exe.

And as for this error:

One possible reason is that the object has been instantiated on one thread and another thread is trying to use it and causing the failure.

1 Like

Hi @AndyMenon ,

Thanks for the response. Yes, I have used studio’s EXCEL SCOPE activity and studioX’s USE EXCEL (scope activity) for same excel file one after another. But i have used CLOSE WORKBOOK activity at the end of Studio’s EXCEL SCOPE activity. Still it throws the error as mentioned above. And StudioX’s Excel activity doesn’t contain close workbook activity, how does it behave if the same file is used in TWO USE EXCEL scope activity one after another?

Often i get the following error too:

Autofit Range: Failed setting the current sheet to: Exchange rate in workbook: File.xlsx. Original error message: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

Even after using close workbook activity, i do get same error.

1 Like

@Gopi_Arumugam , Did you find the solution to your problem. I am facing the same issue and I am working on 2 separate excel files, but both are needed 1 after the another.