Troubleshooting "Microsoft.Office.Interop.Excel.ApplicationClass" error
Who is this article for?
Users who receive an error when attempting to generate a report.
No special access or permissions are required.
This article details the steps for resolving an error message you may encounter when you attempt to generate a report from the system.
1. Issue
When attempting to generate a report, the process fails and an error message is displayed:
EX:0 [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.get_Workbooks()
at AuditVision.Interface.ExcelInstanceManager.NewWorkbook(Application inst)
at AuditVision.AuditPlanning.ActivityPlanning.ExportAuditUniverseOptions.ExportAuditUniverse()
EX:0 [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)
.Office.Interop.Excel.ApplicationClass.get_Workbooks()
at AuditVision.Interface.ExcelInstanceManager.NewWorkbook(Application inst)
at AuditVision.AuditPlanning.ActivityPlanning.ExportAuditUniverseOptions.ExportAuditUniverse()
at MK.Reporting.DOCX.ReportManager.GenerateOutput(Stream outputStream)
at MKInsight.Reporting.Report.LoadFromWordProcessingTemplate(ReportTemplate template, ReportData data, ReportExportType outputFormat, ReportGenerateProgressBar progress)
at.Report.c__DisplayClass53_0.b__0()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at MKInsight.Reporting.ReportManager.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at MKInsight.Reporting.CreateReportForm.d__36.MoveNext()
This error is caused by incorrect COM Interop settings in the Windows registry. This can be caused by installing a newer version of Microsoft Office, and then removing it and installing an older version instead.
2. Resolution
To resolve the issue:
- Back up the registry before making any modifications.
- Follow the steps in the Microsoft article, Unable to cast COM object of Office Interop Word.
- If this not resolve the issue, perform a Microsoft Office repair.
If the problem persists following the repair, a complete reinstallation of the Office suite may be required.