Error – System.InvalidCastException: Unable to cast COM object of type ‘Microsoft.Office.Interop.Excel.ApplicationClass’ to interface type ‘Microsoft.Office.Interop.Excel._Application’

Introduction

A very good friend email me this afternoon that he his working with our corporate support engineer and getting the message pasted below.

Error

Error Image

Error Message

 

Error Message – Details

errorMessage_details__20170621_0523PM

Error Text

 

System.InvalidCastException: Unable to cast COM object of type ‘Microsoft.Office.Interop.Excel.ApplicationClass’ to interface type ‘c._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: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

How did we get here?

Here are what preceded the error message:

  1. A new laptop with Microsoft Office 2016 installed
  2. Tried to use MS Office 2010 based Access Application
    • Corrupted MS Office Access Database
  3. Uninstalled MS Office 2016
  4. Installed MS Office 2010

 

TroubleShooting

Outline

  1. Ensure that MS Excel is installed and running
  2. Attempt to have Application Save file as Excel File and Read directly from Excel
  3. Review Windows Registry
  4. Review Component Services

 

Steps

Ensure that MS Excel is installed and running

Run MS Excel

 

In Application Save File As Excel, Start Excel, and Load File

The problem we were having is with trying to have application use OLE to pass generated data to Excel.

We thus tried out a different track, which is to run query and save the result set into a file.

Once saved in a file, we launch Excel and loaded the generated file.

Review Windows Registry

Regedit or regedt32

Find – 000208D5-0000-0000-C000-000000000046

 

Find – Microsoft.Office.Interop.Excel

 

Map Microsoft.Office.Interop.Excel, Version =w.x.y.z to Office Version

 

Product Version Version ( RTM / SP[n] ) Version #
 Office 2010
 RTM  14.0.0.0
 Office 2007  
 RTM  12.0.4518.1014
 SP1  12.0.6213.1000
 SP2  12.0.6425.1000
 SP3  12.0.6607.1000
 Office 2003
 RTM  11.0.0.0

 

 

Remediation

Control Panel – Programs and Features

Accessed Programs and Features and please do the following:

  1. Installed Features
    • Make sure that the following features are included
      • .NET Programmability Support
  2. Repair
    • Chose to Repair Microsoft Office 2010

 

Once .Net Programmability feature is installed and Repair performed if need be, please reboot computer.

 

Folder

Folder – C:\Windows\assembly

Please review C:\Windows\assembly and look for Microsoft.Office.Interop.* files

The files you want to look for are:

  1. Assembly
    • Microsoft.Office..Interop.Excel
      • Version :- 14.0.0.0

 

References

Office Product & Interop

  1. Office 2007
    • How to determine which version of a 2007 Office product is installed
      Link
  2. Office 2003
    • Installing and Using the Office 2003 Primary Interop Assemblies
      Link

 

Blog – Support

  1. Microsoft
    • Description of the startup switches for Excel
      Link
  2.  act!
    • Error: “Unable to cast COM object of type ‘Microsoft.Office.Interop.Outlook.ApplicationClass’ to interface type ‘Microsoft.Office.Interop.Outlook._Application’… When Synchronizing Act! and Microsoft® Outlook®
      Link
  3. netdocuments
    • “Library Not Registered” error when using EMS in Outlook
      Link

Q/A

  1. COM related exception
    Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s