Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Macro to get file name and file path to a cell

Posted on 2011-09-16
4
Medium Priority
?
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1000 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 93

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 1000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

670 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