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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using ADO within an XLS file

Status
Not open for further replies.

bdbBear

Programmer
Apr 29, 2005
54
US
I have some ADO code within an Excel file (2003) to query data from another Excel file (see below). My question is, how do I grab data from within the same Excel file? What do I set as the connection?

Dim cn As ADODB.Connection
Set cn = New ADODB.Connection

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Open namePath & nameFile
End With

rs.Open q, cn, adOpenStatic
 


Path & filename of your workbook.

Have you tried using MS Query via Data/Get External Data/New Database Query...?



Skip,
[sub]
[glasses] [red]Be Advised![/red]
The band of elderly oriental musicians, known as Ground Cover, is, in reality...
Asian Jasmine![tongue][/sub]
 
Have a look at the FullName property of the Workbook object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top