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.
Hello @AndrewHall I am using 2019.10.3 version. I tried the zipped tool but didnât work. Below is my error code and looks exactly the same as bot82âs.
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.