MSQUERY via VBA

H

Howie

Is there a way to initiate MSQUERY via VBA then capture
the info on exiting so that I can insert the query results
into spreadsheet - also via VBA.
 
D

Dick Kusleika

Howie

Use the Add method of the QueryTables collection. Check VBA help for the
syntax.

In order to get all the arguments you need for that method, the easiest
thing to do is to create a query manually (Data - Get External Data). Then
go to the immediate window and type this

?Sheet1.QueryTables(1).CommandText
?Sheet1.QueryTables(1).Connection

If you get stuck, post back.
 
Top