ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Relative Path in Connection String (https://www.excelbanter.com/excel-discussion-misc-queries/238323-relative-path-connection-string.html)

Breunus

Relative Path in Connection String
 
I am using Excel 2007 to import data from another Excel workbook using
Microsoft Query 2000. The solution works well with a fixed path, but I would
like the connection string to use a relative path (for example the current
directory) so that the files can be copied to a different location and still
function.

I have seen a number of web questions about this topic, but most involve a
programming solution. Is this possible just using Excel? Eg. to specify an
ODBC connection string that would solve the problem.

Jim Thomlinson

Relative Path in Connection String
 
Not possible without resorting to code...
--
HTH...

Jim Thomlinson


"Breunus" wrote:

I am using Excel 2007 to import data from another Excel workbook using
Microsoft Query 2000. The solution works well with a fixed path, but I would
like the connection string to use a relative path (for example the current
directory) so that the files can be copied to a different location and still
function.

I have seen a number of web questions about this topic, but most involve a
programming solution. Is this possible just using Excel? Eg. to specify an
ODBC connection string that would solve the problem.


Lori

Relative Path in Connection String
 
Relative paths can be used in connection strings (as well as formulas and
dialog boxes) but you need to be careful as they are relative to the active
folder¹. So if you were to include a filename without a path it would need to
be in the active folder.

To make sure the current workbook folder is activate you can try choosing
Save As then Cancel, then run the query.

¹ Excel makes a distinction between active folder and workbook folder, which
can be seen from their VBA equivalents: curdir and activeworkbook.path. The
active folder is the one that you see when you click File Open, it can be
changed simply by selecting another folder and cancelling.



"Breunus" wrote:

I am using Excel 2007 to import data from another Excel workbook using
Microsoft Query 2000. The solution works well with a fixed path, but I would
like the connection string to use a relative path (for example the current
directory) so that the files can be copied to a different location and still
function.

I have seen a number of web questions about this topic, but most involve a
programming solution. Is this possible just using Excel? Eg. to specify an
ODBC connection string that would solve the problem.



All times are GMT +1. The time now is 05:10 PM.

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