2

In main part of application I call this line:

Excel.Application ExcelApp = new Excel.Application();

It give me an exception:

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

I tried to run debug in x86, x64 modes is the same result.

enter image description here

POV
  • 11,293
  • 34
  • 107
  • 201
  • 1
    Is Excel installed on this machine? – Hans Kesting Apr 03 '19 at 18:58
  • Yes, and I have imported this using `Excel = Microsoft.Office.Interop.Excel;` – POV Apr 03 '19 at 18:58
  • 1
    The error message indicates that Excel is not installed. Note that having the Excel Interop assembly is not enough; you also need Excel to be installed: https://stackoverflow.com/questions/13660938/com-exception-80040154-when-creating-an-excel-application If Excel really is installed, try reinstalling or repairing the installation. – Joe Apr 03 '19 at 19:51

1 Answers1

1

Try declaring them like this, fully qualified:

Microsoft.Office.Interop.Excel.Application xlapp = new Microsoft.Office.Interop.Excel.Application();

                 Microsoft.Office.Interop.Excel.Application xlApp;
                 Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
                 Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
Alex M
  • 141
  • 2
  • 6