Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

trying to read a excel sheet

 
   Database Help (Home) -> Visual Basic RSS
Next:  Newbie - null values  
Author Message
rob merritt

External


Since: Jun 03, 2004
Posts: 1



(Msg. 1) Posted: Fri Jun 04, 2004 2:36 am
Post subject: trying to read a excel sheet
Archived from groups: comp>lang>basic>visual>database (more info?)

hi i am trying to read data frm 52 worksheets the code below doesnt
wor
any ideas


Dim rst As ADODB.Recordset
Dim oConn As ADODB.Connection
Set oConn = CreateObject("ADODB.Connection")
MsgBox App.Path & "\caretaker.xls"
strSQL = "SELECT * FROM ['29-Dec-2003$']"
oConn.Open "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq="
& App.Path & "\caretaker.xls;DefaultDir=" & App.Path

Set rst = oConn.Execute(strSQL)

 >> Stay informed about: trying to read a excel sheet 
Back to top
Login to vote
Max Kudrenko

External


Since: Jun 09, 2004
Posts: 3



(Msg. 2) Posted: Wed Jun 09, 2004 12:58 pm
Post subject: Re: trying to read a excel sheet [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Robert,

Check this code, it should do something similar to what you need:

Sub test()
Dim rst As ADODB.Recordset
Dim oConn As ADODB.Connection
Dim sPath As String, sTmp As String
sPath = "E:\Doc\Test1.xls"
Set oConn = CreateObject("ADODB.Connection")
oConn.Open "Driver={Microsoft Excel Driver (*.xls)};Dbq=" & sPath & ";"
Set rst = oConn.Execute("SELECT * FROM [Sheet1$]")
Do While Not rst.EOF
sTmp = sTmp & rst.Fields(0) & vbTab & rst.Fields(1) & vbCrLf
Call rst.MoveNext
Loop
Debug.Print sTmp
Call rst.Close
Call oConn.Close
Set rst = Nothing
Set oConn = Nothing
End Sub

Hope this helps,

Max Kudrenko
Brainbench MVP Program for Visual Basic
<a rel="nofollow" style='text-decoration: none;' href="http://www.brainbench.com" target="_blank">www.brainbench.com</a>


merritt.robert RemoveThis @spsd.sk.ca (rob merritt) wrote in message ...
 > hi i am trying to read data frm 52 worksheets the code below doesnt
 > wor
 > any ideas
 >
 > Dim rst As ADODB.Recordset
 > Dim oConn As ADODB.Connection
 > Set oConn = CreateObject("ADODB.Connection")
 > MsgBox App.Path & "\caretaker.xls"
 > strSQL = "SELECT * FROM ['29-Dec-2003$']"
 > oConn.Open "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq="
 > & App.Path & "\caretaker.xls;DefaultDir=" & App.Path
 > Set rst = oConn.Execute(strSQL)

 >> Stay informed about: trying to read a excel sheet 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
sql query returns in wrong format - Hi, Hope someone can help me with this. I have MS SQL 2000 database where i have Table "PriceList" and there a column "Pricemk" wich is data type "money". All data in this column is in form "10001,35". So why when...

arrays - is there a way to concatenate the contents of an array (looping through the array) and storing each item in a comma delimited string? Thanks!

DataReport PageBreak - Hi everyone, I would like to know how to force pagebreak in a datareport for example after 5 records printed. Thank you all

Possible Use of a Cursor - I have a complex query that I hope I can explain it well enough for everyone to understand. I have a table that contains information for work instructions. Contained in the table are "MACHINE_PROC" these are groupings of machining processes....

Scroll Bars - Is there a way to find the size of scrollbars on a system using Visual Basic 6.0? I know how to look and change them on the display properties, but I don't know how to access that information from within Visual Basic.
   Database Help (Home) -> Visual Basic All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]