Question : Excel - 'Excel.Application' is not defined.

I have these Under References  - Microsoft Excel 12.0 Object Library  ver. 1.4.0.0
                    & Microsoft Excel 12.0 Object Library  ver. 2.2.0.0
I have MS office 2007 installed.


I keep getting this error
                   


Error      -   Type 'Excel.Application' is not defined.



For Each myFileinfo In myDir.GetFiles


            Dim excelApp As New Excel.Application
            Dim excelBook As Excel.Workbook = excelApp.Workbooks.Open(myFileinfo.FullName)
            Dim worksheet As Excel.Worksheet = excelBook.Sheets(1)
          etc...


next

Answer : Excel - 'Excel.Application' is not defined.

Hello VBdotnet2005,


Have you add the imports like

Imports Microsoft.Office.Interop.Excel

For Microsoft Excel 11.0 Object Library  you have to do that and I think that's the same for Microsoft Excel 12.0 Object Library  
Random Solutions  
 
programming4us programming4us