ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help to get data from excel 2003 worksheet into Visual Basic 6 (https://www.excelbanter.com/excel-programming/445905-help-get-data-excel-2003-worksheet-into-visual-basic-6-a.html)

Frederick

Help to get data from excel 2003 worksheet into Visual Basic 6
 
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



GS[_2_]

Help to get data from excel 2003 worksheet into Visual Basic 6
 
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




All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com