-1

Error message

I get this error when I am trying to read an Excel file, does anyone know why this is happening?

namespace UseCaseParser
{

    using Excel = Microsoft.Office.Interop.Excel;
    class Program
    {
        static void Main(string[] args)
        {
            Excel.Application xlApp = new Excel.Application();

        }
    }
}
Palle Due
  • 5,929
  • 4
  • 17
  • 32
String
  • 79
  • 1
  • 7
  • 1
    Do you have Excel installed on the machine ? – Selvin Sep 22 '22 at 11:40
  • Yes Excel is installed – String Sep 22 '22 at 11:46
  • You're doing it wrong, nobody can tell you how when you don't tell us what you did. Look [here](https://stackoverflow.com/questions/21013912/can-i-still-use-microsoft-office-interop-assemblies-with-office-2013). – Hans Passant Sep 22 '22 at 11:49
  • I think the path of the excel file is missing – hesolar Sep 22 '22 at 11:57
  • The version of office you have on your system can be different than the version of interop you are referencing in your application (i.e.12), check the office version from about dialog in excel and change the version of the interop referencing accordingly – usmanhaq Sep 23 '22 at 13:01

1 Answers1

1

This happened to me when I used wrong link reference.

Go to Links in Solution Explorer, search for "Interop" in Link manager and select Microsoft.Office.Interop.Excel V15.0.0.0

Rebuild your solution after you add new link.

Microsoft.Office.Interop.Excel Link

EDIT: Also, make sure, your VS version / .NET version is compliant.

Reddi3n
  • 23
  • 5