Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Excel 2k3 query path to current directory

How can you make an EXCEL workbook look for the MS queries (xxx1.DQY) in the
SAME folder in which the workbook and the Access db reside.

The Excel workbook has 6 tabs with pivot tables or query results. This means
there are separate MS queries in each to run corresponding Access queries to
retrieve data from the Access Db. Each month I copy and rename this folder
to run the next month's data. I go in change the directory specified in the
DQY code.

If I just refresh the tab it will run the query against the prior month or
say it can't find it in a specific drive. I have to edit each through the
wizard to erase the old and select the new. I also copy the results to the
network drive which means doing the same editing.
Why can't excel have a setting for the current location path for each
workbook instead of a general default path.

How can I have the workbook/worksheet look in the new folder automatically.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Excel 2k3 query path to current directory

As a worksheet function, in any cell on any sheet:
=LEFT(CELL("filename"),FIND("[",CELL("filename"))-1)
this will return the full path of a workbook that has been saved (when you
first put the formula into a new workbook as Book1.xls, it shows nothing
until after saving and reopen, after that it stays current).

In VBA code:
Sub FindMe()
Dim PathToMe As String
PathToMe = Left(ThisWorkbook.FullName, _
Len(ThisWorkbook.FullName) - Len(ThisWorkbook.Name))
MsgBox PathToMe
End Sub

Same restriction - nothing returned untill after the workbook has been saved.


"busypgmr" wrote:

How can you make an EXCEL workbook look for the MS queries (xxx1.DQY) in the
SAME folder in which the workbook and the Access db reside.

The Excel workbook has 6 tabs with pivot tables or query results. This means
there are separate MS queries in each to run corresponding Access queries to
retrieve data from the Access Db. Each month I copy and rename this folder
to run the next month's data. I go in change the directory specified in the
DQY code.

If I just refresh the tab it will run the query against the prior month or
say it can't find it in a specific drive. I have to edit each through the
wizard to erase the old and select the new. I also copy the results to the
network drive which means doing the same editing.
Why can't excel have a setting for the current location path for each
workbook instead of a general default path.

How can I have the workbook/worksheet look in the new folder automatically.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database query to import from Access to Excel David T Excel Discussion (Misc queries) 0 August 31st 06 07:12 PM
Get External Data - not editable using Query Wizard MargaretBeckbury Excel Discussion (Misc queries) 7 January 17th 06 09:13 AM
Renaming Access Query used by Excel UEUC2 Excel Discussion (Misc queries) 1 December 13th 05 05:19 PM
auto file path update when excel sheet moved to another directory. GNSBoy Excel Discussion (Misc queries) 1 August 31st 05 07:46 PM
Micosoft Query does not export result set to excel Peter McAuley Excel Worksheet Functions 0 June 16th 05 08:53 PM


All times are GMT +1. The time now is 12:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"