Get File Path in VBA

Display file path to the current workbook

In order to create a simple subroutine that shows a path to the active workbook follows these steps.

  1. Open VBA Editor (Alt + F11),
  2. Insert the following code into your project.

It will display three dialog boxes:

  • the full file path,
  • directory_path,
  • file_name + extension

You can also create functions to show you data inside a cell. First, create a module for your worksheet. This easy function will show you a path to the current file inside a cell.

As you can see, the function name is inserted into the cell.

Tomasz Decker is an Excel specialist, skilled in data analysis and financial modeling.