How can I find the name of the currently open Excel document using VBA?

I am using VBA in Excel to read a spreadsheet and modify its contents. I need to save the results with a name similar to the source file, but with some changes.

How can I programmatically find the name of the current open file using vba?

+4
source share
2 answers

It depends, here are two possibilities:

Debug.Print ActiveWorkbook.Name For Each wk In Workbooks Debug.Print wk.Name Next 
+5
source

ThisWorkbook.Name will return the file name. ThisWorkbook.FullName will return the directory structure and file name.

+7
source

All Articles