I want to open Excel 2007 file then retrieve some data inside. I used this code, let's say under Form1_Load:
Dim xlApp As New Excel.Application, xlWorkbook As Excel.Workbook
Dim xlWorksheet As Excel.Worksheet
' The following line always fails
xlWorkbook = xlApp.Workbooks.Open(My.Application.Info.DirectoryPath & _
xlWorksheet = xlWorkbook.Sheets("April 2008")
Label1.Text = xlWorksheet.Cells("B2")
Catch ex As Exception
I have added a reference to Microsoft Excel 12.0 Object Library.
When I test this code, I always get an error:
Old format or invalid type library.
(Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))
Â Â Â at Microsoft.Office.Interop.Excel.Workbooks.Open(Stri ng Filename,
Object UpdateLinks, Object ReadOnly, Object Format, Object Password,
Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin,
Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru,
Object Local, Object CorruptLoad)
Â Â Â at Sample.Form3.Form3_Load(Object sender, EventArgs e) in
D:\My Documents\Visual Studio 2008\Projects\Sample\Sample\Form3.vb
2008 samples about Excel application also don't work and throw the same exception.
I already did a workaround as written here: http://blogs.msdn.com/eric_carter/ar...15/429515.aspx
(since my locale is set to Indonesian), but it also didn't work.
Does anyone know how to overcome this in VB
2008 Express Edition?