Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Talking to Excel

How do I get data to Excel? by calculus
Posted: 26 Aug 03

I've always wondered how to do this, so now that I've figured it out (with direction provided from Camel2021 in a post from 7-22-02) I thought I'd share with everyone else.

You just have to create several objects to use Excel as a database as shown below.

Dim adoConn as object
Dim RS as object
Dim TableRS as object
Dim strConString as string
Dim FileName as String

Set adoConn = createobject("ADODB.CONNECTION")
Set RS = CreateObject("ADODB.Recordset")
Set TableRS = CreateObject("ADODB.Recordset")
'To be used to enumerate the worksheets in Excel

Path = "C:\MyPath\"
FileName = "MyFile.xls"
DataFile = Path & FileName

    StrConString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
               "Data Source=" & _
               DataFile & ";" & _
               "Extended Properties=""Excel 8.0;HDR=Yes"""
    adoConn.open strConString

    set TableRS = adoConn.OpenSchema(20) 'Get Sheet List

'Enumerate these by looping through the TableRS recordset as normal
    SheetName = TableRS.Fields("TABLE_NAME")

    SQL = "Select * from [" & SheetName & "$] Where [F1] = #" & MyDate & "#"
        RS.open SQL, adoConn, 2,3     'adOpenDynamic, adLockOptimistic
        RS.Fields(1).Value = MyValue


I hope you find this helpful.

Back to AttachMate solutions FAQ Index
Back to AttachMate solutions Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close