Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel._Workbook'

Hi all,

I am executing macro within excel application scope but got the below error:

Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Microsoft.Office.Interop.Excel._Workbook’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{000208DA-0000-0000-C000-000000000046}’ failed due to the following error: System call failed. (Exception from HRESULT: 0x80010100 (RPC_E_SYS_CALL_FAILED)).

RemoteException wrapping System.InvalidCastException: Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Microsoft.Office.Interop.Excel._Workbook’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{000208DA-0000-0000-C000-000000000046}’ failed due to the following error: System call failed. (Exception from HRESULT: 0x80010100 (RPC_E_SYS_CALL_FAILED)).
at UiPath.Excel.Activities.ExecuteMacro.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)
— 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)

The problem is the uipath couldn’t close excel after done. (And note that I didn’t use any close workbook in vba code)

The workflow was run smoothly on the local machine but through error when I try to run on production via orchestrator. I have read many topics but still didn’t find the correct solutions in this situation. Can anyone please assist?

Hi @BoBo

Are you still having similar issues? I had some problems executing a macro using Uipath that sounds quite similar. Do you have a pop up message in excel once the macro has finished running?

yes I am still having the problem. There were no error on front end. It just failed job on orchestrator and the log showed the above error. Are you facing the same?

Hi @BoBo

Have you tried using the workbook activities instead?

I did have similar issues but it was because the Macro had a pop up message at the end to say that it had completed running. This mean uipath couldn’t identify that the macro had finished running and the activity eventually timed out ‘Waiting for the macro to finish running’. I had to use the run macro activity and close pop up inside a parallell activity to stop the error. If this sounds similar happy to send over more info.

I think execute macro activity only works inside excel application scope. Is it correct?

I think my issues is different with yours. But I have fixed it by disabling the “Visible” checkbox in excel application scope. Hope this will help others in the future.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.