Frederick used his keyboard to write :
Hi I am trying but without success to get data from an excel 2003 spreadsheet
into Visual Basic 6 I have tried to use the following code but to no
avail.Any suggestions please would be really appreciated.RegardsFredSub
OpenExcel7Sheet()
Dim dbs As Database
Dim rst As Recordset
Dim intNumRecords As Integer
' Open the Microsoft Excel workbook named Data.xls without exclusive access
' and with read/write permissions.
Set dbs = OpenDatabase("C:\Excel\Data.xls",False, False, "Excel
5.0;HDR=No;")
' Create a Recordset from the worksheet. The dollar sign character following
' the sheet name tells the installable ISAM that the code is referencing the
' entire sheet.
Set rst = dbs.OpenRecordset("SampleSheet$")
' Use the MoveLast method to populate the Recordset; use the RecordCount
' property to count the records and display a message that gives the
results.
rst.MoveLast
intNumRecords = rst.RecordCount
MsgBox "There are " & intNumRecords & " rows in this worksheet."
rst.Close
End Sub
Check my reply to your other post in 'microsoft.excel.misc'!
--
Garry
Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.
vb.general.discussion