Solved

Macro to get file name and file path to a cell

Posted on 2011-09-16
4
339 Views
Last Modified: 2012-05-12
Dear Experts,
I'm looking for a function like =Now() which returns date/time into a cell. Same idea but I want as return the path and the file name like this: \\evofiles\jg library\12-Quality\2-Internal\3-Projects\Document Registration\Document_Registration_DRAFT.xlsm

Is there a ready command? Could such command be added as add in or macro?

As alternative variant but not as good would be just a macro which I can add to my quick access toolbar then..

thanks


0
Comment
Question by:Petersburg1
4 Comments
 
LVL 33

Expert Comment

by:jppinto
ID: 36548828
Just insert a new module on your VBA editor and insert this custom function. Then on your sheet, just insert like this:

=FileName()

and you will get something like this:

D:\Experts_Exchange\FileName.xlsm

jppinto
Function FileName()
    FileName = ActiveWorkbook.FullName
End Function

Open in new window

0
 
LVL 17

Accepted Solution

by:
andrewssd3 earned 250 total points
ID: 36548829
=CELL("filename")

Open in new window


does this, but it includes the worksheet name as well - you could trim this off later.
0
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 250 total points
ID: 36548843
As long as the file has been saved:

=SUBSTITUTE(LEFT(CELL("filename"),FIND("]",CELL("filename"))-1),"[","")
0
 

Author Closing Comment

by:Petersburg1
ID: 36548877
Perfect! And so quick
thank you
Nils
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question