There are many times when it is useful to be able to retrieve the location of the Excel file you are currently working on when you are trying to retrieve values from another Excel file or save a file as a name using a macro. In this article, we will show you how to use the "Path" command, which is useful in such cases.
To easily see where the currently open Excel file is savedAllows you to see the address where the book is saved Excel (Excel)Please also refer to the article on
Also, if you want to get the file name, not just the location of the file, you can use theGet the full path (save location and file name) of the opened Excel file "FullName" Excel (Excel) Macro (VBA)See also.
I would like to save an Excel file in a folder called "TEST" on my "desktop" and then put the VBA together in that Excel file.
Display in message box
Sub Show Save Location()
MsgBox ThisWorkbook.Path
End Sub
If you run this macro, you will see

A message box like this appeared.
Write to cell
Sub Create List()
Range("B3").Value = ThisWorkbook.Path
End Sub
If you run this macro, you will see

Thus, the "B3" cell could display the destination folder for this Excel file.
Conclusion
In this case, we added "Path" to "ThisWorkbook" to obtain the storage location, but "ActiveWorkbook" can be used in the same way.
You can also use "FullName" to get even the file name. For more information, seeGet the full path (save location and file name) of the opened Excel file "FullName" Excel (Excel) Macro (VBA)See also.
Comment