Sometimes it is useful to get the file name using Excel VBA. Two methods will either give the file name, or the full file path and file name. When I use either of these methods I tend to assign them to a variable as a string.
Get File Name using VBA
Using VBA I would assign the file name to the variable thus so. Assuming you want to capture the filename of the workbook currently open I would add two lines of code. One to declare the variable, and one to assign the file name to the variable.
Dim FileName as String
FileName = ThisWorkbook.Name
Get File Path & File Name using VBA
To get the file path and file name of the active workbook I would use the same method as above, but change the second line ever so slightly.
Dim FullFileName as String
FullFileName = ThisWorkbook.FullName
So using the examples above will generate the following variables. These are examples only, and file paths will differ: