Error trying to work with a excel workbook

ME_

New member
Joined
Jun 11, 2003
Messages
1
When im trying to execute the folowing code i get an error, i dont know how to get ride of it, help is needed

Im trying to execute the folowing code :

Private xlsApp As Excel.Application
Private xlsBook As Excel.Workbook
Private xlsSheet As Excel.Sheets
Sub New(ByVal file As String)
If file.EndsWith(".xls") Then
xlsApp = GetObject(, "Excel.Application")
If xlsApp Is Nothing Then
xlsApp = CreateObject("Excel.Application")
End If
xlsBook = xlsApp.Workbooks.Add
xlsApp.Visible = True
End If
End Sub


I get the folowing error:

Unhandled Exception: System.Runtime.InteropServices.COMException (0x80028018): Oude indeling of ongeldig type DLL-bestand.
(translation: old lay-out or invallid type DLL-file.)
at Excel.Workbooks.Add(Object Template)

Im using Microsoft Excel 10.0 Object Library

I also tryed xlsApp.Workbooks.Open(file) resulting in the same error. Any sugesstions?
 
According to my book, the part that is wrong is the Workbook.Add method call try something like this:
Add a normal workbook (1 blank worksheet)
xlsApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet)
 
Back
Top