If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Function to get the current path/directory

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-02-09, 07:15
LimaCharlie LimaCharlie is offline
Registered User
 
Join Date: Oct 2005
Posts: 119
Function to get the current path/directory

What is the function to get the durrent path/directory of where my file is?

I have an excel file in which cell (A1) should contain/display the current path or directory where this said file is saved? What is that function pls.?

Thanks a lot.
Reply With Quote
  #2 (permalink)  
Old 09-02-09, 08:40
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
You can set it through VBA, use Application.Path

Regards,

Ax
Reply With Quote
  #3 (permalink)  
Old 09-02-09, 08:52
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
Hi

I think to get the directory of the Excel file running the code you need this

ThisWorkbook.Path

Application.Path returns the diectory of Excel.exe !!?

HTH


MTB
Reply With Quote
  #4 (permalink)  
Old 09-02-09, 09:07
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
Yeah, you're right, you'll want to use ActiveWorkbook.Path. My bad.
Reply With Quote
  #5 (permalink)  
Old 09-22-09, 16:20
pierrevbaexcel pierrevbaexcel is offline
Registered User
 
Join Date: Dec 2003
Location: Ottawa, Canada
Posts: 72
hi

You could also use the CELL function in Excel:

If you want the name and path of the active spreadsheet to be entered automatically in a cell, use the formula: =CELL("filename" )

if you want only the filename use :
=MID(CELL("filename" ,A1),FIND("[" ,CELL("filename" ,A1))+1,FIND("]" ,CELL("filename" ,A1))-FIND("[" ,CELL("filename",A1))-1)
__________________
A piece of data is like a brick
If you don't build anything with it
It is just a brick
www.excel-examples.com
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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