ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MS Query (https://www.excelbanter.com/excel-programming/275247-ms-query.html)

Tom Ulincy[_2_]

MS Query
 
I recorded a procedure that includes a query (MS Query,
Excel 2002) to an external data source. The result set is
returned to a sheet in the workbook. How do you change,
or better yet, programmatically specify, the destination
path for the result set? Right now, if I move the
workbook to another folder, the query fails.

Thanks for your help.
Tom


Dick Kusleika

MS Query
 
Tom

That shouldn't happen normally. The external data source is hardcoded (full
path) into the QueryTables Connection and CommandText properties. The
destination of the result set is a Range object stored in the Destination
property. When you add a QueryTable, you use the QueryTables property of
the Worksheet object.

Sheet1.QueryTables.Add ...

So it shouldn't matter where the you run this code, it will always go to
Sheet1 of the ActiveWorkbook. Post the code that you are using and the
exact error message.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Tom Ulincy" wrote in message
...
I recorded a procedure that includes a query (MS Query,
Excel 2002) to an external data source. The result set is
returned to a sheet in the workbook. How do you change,
or better yet, programmatically specify, the destination
path for the result set? Right now, if I move the
workbook to another folder, the query fails.

Thanks for your help.
Tom





All times are GMT +1. The time now is 07:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com