Read/write in Excel 2007

impel123

New member
Joined
Jan 9, 2010
Messages
3
Programming Experience
Beginner
hi all,

i am using visual studio 2008,framework 3.5, and i would like to make a windows form application that will store and retrieve data drom ms Excel 2007. Every code i found on internet doesn't work...:(

So, could anybody give me the code needed to:
1)when i press button1,i would like to store in cell A1 THE TEXT "OK"
2)when i press button2,i would like to read the value in cell A1.

Assume that excel 2007 file is in "c:\Database.xlsx" and the workbook has only one worksheet with name "DatabaseWS".i have added reference "Microsoft Excel 12.0",and " Imports Microsoft.Office.Interop"
in the top of form1.vb.
tnx:(

code:
Dim objBooks As Excel.Workbooks
Dim objSheets As Excel.Sheets
Dim objSheet As Excel._Worksheet
Dim range As Excel.Range

' Create a new instance of Excel and start a new workbook.
objApp = New Excel.Application()
objBooks = objApp.Workbooks
objBook = objBooks.Add


the error is in the last line "objBook = objBooks.Add" saing:

Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))
 
Last edited:
Back
Top