Excel VBA, Get Current File Path and Name

In this article I will explain how you can get the current path and name of the file you are working with.


File Path:

The file path can be obtained using the code below:

Dim strPath As String
strPath = ThisWorkbook.FullName
MsgBox (strPath)

Result:

Get Current File Path Excl
Note: If the file has not been saved yet you will get something like this:

File Not Saved Full Path


Get File Name:

The file name can be obtained using the code below:

Dim strPath As String
strPath = ThisWorkbook.Name
MsgBox (strPath)

Result:

File Name
You can download the file and code related to this article from the link below:

See also:

If you need assistance with your code, or you are looking for a VBA programmer to hire feel free to contact me. Also please visit my website  www.software-solutions-online.com

3 thoughts on “Excel VBA, Get Current File Path and Name”

Leave a Reply

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