Output the File Path to and Name of a Workbook in Excel - UDF

Add to Favorites

Free Excel UDF (user defined function) that displays the full file path and name of an Excel workbook. This function is very easy to use since it requires no arguments in order to function. It is a very simple and easy way to return the location of the current workbook including the workbook's name and file extension.

There are many different reasons you might want to use this macro; it is great if you aren't sure where an open Excel workbook file is saved on your computer or on the network; it allows you to display information about a workbook if you have disabled other features such as the menu system in Excel; etc.

Where to install the macro:  Module

UDF to Output the File Path to and Name of a Workbook in Excel

Function NAMEWBKFILEPATH() As String

NAMEWBKFILEPATH = ThisWorkbook.FullName

End Function








How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.


Excel Forum