Error when opening a Excel file in C# RRS feed

  • Question

  • rQuestion
    You cannot vote on your own post


    I have an issue which it was suggested should be referred to this site...

    I have 3 machines, all running Windows Pro 10 x64.  The following code is successful on 2 of the machines, but not the 3rd.  I am having this exception when I try to open the .xlsx file.

    My Excel class contains:

    using Microsoft.Office.Interop.Excel;
    using _Excel = Microsoft.Office.Interop.Excel;

    namespace ExcelTest
        class Excel
            //global reference
            string path = "";
            _Application excel = new _Excel.Application();
            Workbook wb;
            Worksheet ws;

            public Excel(string path, int sheet)
                this.path = path;
                wb = excel.Workbooks.Open(path);
                ws = wb.Worksheets[sheet];


    On executing "wb = excel.Workbooks.Open(path);"  I get the following error:





    {"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: Interface not registered (Exception from HRESULT: 0x80040155)."}


    I have uninstalled office, restarted the machine and re-installed.  I  even recreated a a new test app on this machine where I added a new reference to Excel, and still the problem persists. 

    I have only recently started using Office 365 and installed it on all 3 machines about the same time. The version numbers are the same - 16.011425.20228.  

    What program is it looking for?  Are there some Office Tools I should be installing?

    Help!  Please! I need to fix this.



    • Edited by Soozi-Wong Thursday, May 2, 2019 6:48 AM
    Thursday, May 2, 2019 6:47 AM


  • Problem solved!!

    I installed Visual Studio 2017 (Community)  Tools for Office 2013 on all three machines and approached the programming in a different way, but the download was the essential detail.

    Thanks to anyone who mulled over this problem for me.


    • Marked as answer by Soozi-Wong Friday, May 3, 2019 4:00 PM
    Friday, May 3, 2019 3:59 PM