HomeMicrosoft OfficeExcelHow to Get the File Path and File Name using Excel VBA?

How to Get the File Path and File Name using Excel VBA?

In this post, you will be learning how to get the full File Path and File name using Excel VBA in your Excel Spreadsheet.

The file path and file name using Excel VBA can be accessed using the ‘.Path’ and ‘.FullName‘ properties.

How to Get the File Path using Excel VBA?

.Path Property

The Path property returns the complete, saved path of the workbook -Excel file.

How to Get File Name using Excel VBA?

.FullName Property

The FullName property returns the complete, saved path, including the name of the workbook.

Let’s see these properties with the help of an example.

  • Create an Excel file and name it of your choice.
  • Firstly, place a command button on your worksheet using the insert option in the Developer tab
How to Get File Name using Excel VBA?

 Enter the following code in the VBA of the button:

How to Get the File Path and File Name using Excel VBA?
MsgBox Workbooks("Developerpublish.com-Path and full name.xlsm.xlsm").Path

This returns the complete path to the current excel file.

How to Get the File Path and File Name using Excel VBA?
MsgBox ActiveWorkbook.FullName

This line returns the complete path, including the name of the active workbook.

How to Get the File Path and File Name using Excel VBA?

You need to enter the exact file name to find its path.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this article, you will learn about the SKEW.P function, the formula syntax and usage of the function in Microsoft...
In this article, you will learn about the SKEW function, the formula syntax and usage of the function in Microsoft...
In this article, you will learn about the RANK.EQ function, the formula syntax and usage of the function in Microsoft...
  • Excel
  • November 23, 2021