Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a spreadsheet and get the data 1

Status
Not open for further replies.

easycode

Programmer
Jan 28, 2005
195
US
Hello all,

i am new to pure vb 6.0 but i have experience in vba
I found that is easy to open an access database and retrieve information using ado in VB 6.0 but what i need to do is open an excel spreadsheet, process data and then generate a report using vb, can anyone lead me to the right direction. Thanks
Any help is appreciated!
 
You could use ADO to do this as well:

Code:
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=C:\YOUREXCELFILENAME.XLS;" & _
           "Extended Properties=""Excel 8.0;HDR=NO"""
    
rs.Open "SELECT * FROM [Sheet1$]", conn

Swi
 
How would you do this in VBA? If you have experience with VBA in Access, this should be an easy task, because there are few differences between VBA and VB 6.

You may get a better answer to your question in the Access Forums.

SWI is correct, except there are a few things you should realize.

1) He has the format for the XL sheet without a header. If your XL sheet has a header, his/her code will bring back the header as a record.

2) If the sheet name has a space in it, it needs to be referenced like this: rs.Open "SELECT * FROM ['Sheet 1'$]"

I hope this helps.

Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top