Excel tip: Insert filename in a cellDate: 6 february 2002
The following formulas will include the filename, filepath, of filepath and name in a cell in your workbook.
If you've installed ASAP Utilities, you already have these formulas. Just type one of the formula names, i.e. "=ASAPFileName()" in a cell.
Copy-paste friendly code:
Public Function ASAPFullFileName() As String
' returns the path and file name
' for example D:\Projects\testfile.xls
ASAPFullFileName = ActiveWorkbook.FullName
Public Function ASAPFileName() As String
' returns the file name without its path
' for example testfile.xls
ASAPFileName = ActiveWorkbook.Name
Public Function ASAPFilePath() As String
' returns the path without the file name
' for example D:\Projects
ASAPFilePath = ActiveWorkbook.Path
If you have the international version of Excel you can also use the following worksheet function:
Chip Pearson has written some nice examples on his website about how to return a file name.
Share this page:
List of all utilities
Printer friendly page
^ Back to Top