Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic and Excel 2003 and 2007? playerbigdog Excel Programming 12 May 29th 08 08:05 PM
Excel 2003 visual basic for 'spinbutton' Browny Excel Discussion (Misc queries) 2 May 9th 08 06:46 AM
Excel 2003 visual basic help shows nothing p45cal[_50_] Excel Programming 2 May 11th 07 11:27 AM
Can Visual Basic 2005 be used in Excel 2003? atesolutions Excel Programming 1 January 11th 06 01:47 PM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM


All times are GMT +1. The time now is 01:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"