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:
Note: If the file has not been saved yet you will get something like this:
–
Get File Name:
The file name can be obtained using the code below:
Dim strPath As String
strPath = ThisWorkbook.Name
MsgBox (strPath)
Result:
You can download the file and code related to this article from the link below:
See also:
- VBA Save File Dialog, FileDialog(msoFileDialogSaveAs)
- Excel VBA Save File Dialog, GetSaveAsFilename()
- Excel VBA Open File Dialog
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”