Search code examples
c#excelcomadd-in

C# Open Workbook Returns Addin not Workbook


I am having a strange error, it was working a few days ago, I'm not sure what changed.

I'm using the Microsoft Excel 14.0 Object Library (version 1.7) and the Microsoft.Office.Interop.Excel namespace.

when I run the following lines of code

EXCEL_APP = new Excel.Application();
currentIR = EXCEL_APP.Workbooks.Open(irFilePath);

When I look at the object currentIR is set to an add-in that is on my computer and not the workbook (given in the file path);

Has anyone had something like this happen?

Workbook Object is Add-in

I can give more details as needed.

Thanks


Solution

  • This doesn't directly answer why the issue was happening, but I got around it by first opening the workbook, then setting my workbook object equal to the open workbook.

    EXCEL_APP.Workbooks.Open(irFilePath);
    string irName = Path.GetFileName(irFilePath);
    currentIR = EXCEL_APP.Workbooks[irName];