3

I am developing an Autodesk Revit addin that communicates with Excel and performs some standard read/write operations on cells. I have referenced Microsoft.Office.Interop.Excel (v12.0.0.0), because some users might have Office 2007 installed instead of 2010 or later. I use Visual Studio 2013. Here is the beginning of the code;

Excel.Application xlApp;
    Excel.Workbook xlWorkBook;
    Excel.Worksheet xlWorkSheet;
    object misValue = System.Reflection.Missing.Value;

    xlApp = new Excel.Application();

However, on some computers this returns the folowing error:

Revit encountered a System.Runtime.InteropServices.COMException(0x80040154): Retrieving the COM class factory for component with CLSID (00024500-000-0000-C000-000000000046) failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

It works on several computers that are 64-bit/32-bit, have Office 2007/2010/2013 installed. But it also doesn't work on other computers that have the same specs. How can I find out what is wrong?

EDIT: The error is returned at this specific line: xlApp = new Excel.Application();

Someone suggested registering the dll, but that doesn't work for Microsoft.Office.Interop; HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

Community
  • 1
  • 1

1 Answers1

1

I have probably found the answer here: Excel interop works on machine with Office 2007 but fails on machine with Office 2010

The problem machine has Office, but it is set up as click-to-run (runs off the internet) rather than MSI-based (runs from an EXE). This means that certain registry settings, DLLs, components, etc. are not available to Microsoft.Office.Interop.Excel, so it fails.

It is possible to switch from Office Click-to-Run to MSI-based Office.

Community
  • 1
  • 1
  • Does that mean that Office Interop fails completely on the click-to-run machines, and that even late-binding isn't possible? – kaefer Mar 04 '14 at 14:41
  • I have reinstalled Office on the machines using MSI-based installation, and now it works. – user3086984 Mar 04 '14 at 15:36