Scenario: Trying to execute macro in Excel Application Scope and an error appears. If I execute the macro manually it works. I searched in other topics for a solution and I couldn’t find one.
Cadences has thrown an exception
Message: 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)).
Source: Execute macro
Exception Type: InvalidCastException
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)
Steps to reproduce: In Excel Application Scope use Execute macro and run the flow.
Current Behavior: Exception thrown: InvalidCastException
Expected Behavior: To run macro successfully as before.
Studio/Robot/Orchestrator Version: 2016.6274
Last stable behavior: Worflow execution successfully run the macro.
Last stable version: 2016.6274
OS Version: Windows 7 Enterprise 64-bit
Others if Relevant: (workflow, logs, .net version, service pack, etc):
Noticed that having the “.xlsm” file in another folder location doesn’t bring any errors.
In my case, I included “workbooks.close” which kills EXCEL workbook which includes execute macro activity.
It means self-killing, that’s why this error occurred.
After I removed “workbooks.close”, this issued was solved.
Were you able to find a solution to this problem? I am facing the same issue. And an office repair / office re-installation didn’t help me.
Kindly let me know.
-Open the macroEnabledExcelFile with Run command by using SendHotkey and TypeInto;
-Open MacroWindow in Excel by using Send hotkey and DoubleClick on MacroName;
-Used OnElementAppear to check when macroExecution has ended;
-Save Excel using SendHotkey;
-Close Excel…
I unchecked the Visible property of Excel Application Scope from which the ExecuteMacro Activity was being called. And it worked for me. The issue in my case was around the screen update during macro execution.
I have faced with this case. Although I unchecked the Visible property, it’s still didn’t work.
Then I tried to let screen updating = false in my vba code. It’s solved.
Hope it help some one if they got similar sistuation.