Hello, when I run my code, the first activity is to open an excel file and I get an error. I have not made any changes to the code since the last time I ran the bot and now I get an error with the message below:
Since I did not make any changes I decided to run a test file from UiPath Academy (Book Sales Report from the Excel Automation with StudioX course) and this gives me the same error as the first activity is also to open an excel file. This makes me believe there is an issue with my UiPath or Excel system rather than code. Can anyone advise on next steps to fix this?
Error opening workbook. Make sure Excel is installed. Unable to cast COM object of type ‘Microsoft.Office.Interop.Excel.ApplicationClass’ to interface type ‘Microsoft.Office.Interop.Excel._Application’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{000208D5-0000-0000-C000-000000000046}’ failed due to the following error: Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND)).
@bot82 This is usually caused by a bug in the installer for Microsoft Office where it leaves Excel unregistered with Windows such that it can’t be found by automation applications (basically UiPath dials Excel’s phone number, and Windows connects the call, this bug causes Excel to forget to register with Windows).
If you have StudioX 20.10 or newer, the fix is to run the Office Repair tool we’ve provided in the product Microsoft Office Issues.
If you aren’t on a 20.10 version, let me know and we can get you a standalone version.
Unzip, and run the “RunRepairTool.bat” to launch it. Note: You can generate a repair plan without admin rights, but applying the repair options will require administrative rights on the machine.
Message: Error opening workbook. Make sure Excel is installed.
Exception Type: System.Exception
RemoteException wrapping System.Exception: Error opening workbook. Make sure Excel is installed. —> RemoteException wrapping System.InvalidCastException: Unable to cast COM object of type ‘Microsoft.Office.Interop.Excel.ApplicationClass’ to interface type ‘Microsoft.Office.Interop.Excel._Application’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{000208D5-0000-0000-C000-000000000046}’ failed due to the following error: Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND)).
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at Microsoft.Office.Interop.Excel.ApplicationClass.set_SheetsInNewWorkbook(Int32 RHS)
at UiPath.Excel.WorkbookApplication.StartNewApplication()
— End of inner exception stack trace —
at UiPath.Excel.WorkbookApplication.StartNewApplication()
at UiPath.Excel.WorkbookApplication.InitializeExcelApp()
at UiPath.Excel.Activities.ExcelApplicationScope.<>c.<.ctor>b__48_0(WorkbookArguments args)
at UiPath.Excel.Activities.ExcelApplicationScope.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)
@Shuxian just to confirm, you opened the tool Generated the repair plan, and did “Run repair actions” which then requested admin privileges all from the Excel tab? I’m confirming as it’s easy to miss the “Run repair actions” step as just clicking “Generate repair plan” doesn’t make any changes on the machine.