F
Frederick
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
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