Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error importing and exporting excel data to vb.net, "Microsoft.Office.Interop.Excel.Application is not defined"

Tags:

excel

vb.net

vba

I am trying to run a file I downloaded to import and export data from excel. I downloaded from from the following site:

http://www.sattsoft.com/sourcecodes/details/1/9/import-export-data-to-excel-using-vb-net.html

When I run the file the error comes on the following lines

    Dim xlApp As Microsoft.Office.Interop.Excel.Application
    Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
    Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet

These are the errors that come on those respective lines

Type "Microsoft.Office.Interop.Excel.Application is not defined"

Type "Microsoft.Office.Interop.Excel.Workbook is not defined"

Type "Microsoft.Office.Interop.Excel.Worksheet is not defined"

What I want to do is to run the file without the errors so that I can import and export data from excel to vb.net datagridview. I am using Excel 2010 and visual studio 2010

How do I get around this error so I can run the file?

like image 935
Ahmed Faizan Avatar asked Jan 07 '14 13:01

Ahmed Faizan


People also ask

Do I need to have Office installed to use Microsoft Office Interop Excel DLL?

Yes, you are right. You need Excel to be installed to use the Excel Manipulation feature with Microsoft. Office. Interop.


1 Answers

Add COM reference Microsoft.Office.Interop.Excel to your project, it's called Microsoft Excel XX.Y Object Library (XX.Y is version number depending of installed Excel).

like image 95
David Sdot Avatar answered Sep 20 '22 11:09

David Sdot