This is my workflow. I am trying to execute an Invoke VBA activity inside an Excel Application Scope.
However I am getting this error:
Invoke VBA - CompareGroup123: 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: The requested object does not exist. (0x80010114). Attached is the screenshot of my process :
This Error occurs while executing the VBA Script\CompareGroup123.vbs VBA script which is executed using the Invoke VBA - CompareGroup123 activity. 3_ProcessDataCustomer.xaml (32.1 KB)
Which is just above the “Throw” activity which I added just for to stop the process whenever I test it.
The thing is this. This error occurs even if the VBA script has nothing but just declaration of variables in it. Which makes me believe that the error has nothing to do with the Script itself.
Another thing that I had observed is that the error doesn’t occcur if I comment out the Excel Application Scope that has the Copy Sheet - Group123List activity which comes before the Invoke VBA - CompareGroup123 activity whose properties are as shown below
Ugh, that “Unable to cast COM object” error is the worst!
The fact that it works when you comment out the previous Copy Sheet activity is a massive clue. That 0x80010114 code usually means the COM object (the Excel instance) is getting released or closed before your Invoke VBA activity can grab it, making it “The requested object does not exist.”
Try this: Put both the Copy Sheet and the Invoke VBA activities inside one single Excel Application Scope that opens the target file. That way, you guarantee they’re both using the same live Excel instance.
Mismatch in Excel versions or Interop assemblies:
Make sure the UiPath Excel activities package and the Microsoft Office version installed are compatible. Updating the UiPath.Excel.Activities package to the latest stable version may help.
Invoke VBA activity scope issues:
The Invoke VBA activity must be executed inside an Excel Application Scope, and it expects the scope’s workbook to be correctly referenced. Check if you have multiple Excel Application Scopes nested or conflicting activities that may cause ambiguity in the workbook reference.
Corrupted Excel file or VBA macro:
Try running the VBA macro manually inside Excel to verify it works as expected. Any corruption or code issues could interfere.
Recommended Debug Steps
1.Close all Excel instances.
2.Open Excel Application Scope targeting your specific file.
3.Run the VBA macro “CompareGroup123” manually inside Excel to verify it works.Recreate the Invoke VBA activity inside the same Excel Application Scope, ensuring no nested or conflicting scopes.Update
4.UiPath.Excel.Activities package to the latest.If still failing, try using the “Execute Macro” activity as an alternative.
Excel keeps an internal hidden workbook after copying sheets.
When Invoke VBA runs in the same scope, UiPath cannot identify the correct workbook and throws the COM error.
Use one Excel Application Scope only for copying the sheet.
Perform Copy Sheet
Save the file
Close the scope
Create a second Excel Application Scope.
Open the same file again
Run the Invoke VBA activity here
If Excel still stays open from the first scope, add Kill Process (EXCEL) before the second scope.
If helpful, mark as solution. Happy automation with UiPath