How can I find the name of the currently open Excel document using VBA?
I'm using VBA in Excel to read a spreadsheet and modify its contents. I need to save the results with a name that is s开发者_StackOverflowimilar to the original file, but with some alterations.
How can I programmatically find the name of the currently open file using vba?
ThisWorkbook.Name
will return the file name.
ThisWorkbook.FullName
will return the directory structure and the file name.
It depends, here are two possibilities:
Debug.Print ActiveWorkbook.Name
For Each wk In Workbooks
Debug.Print wk.Name
Next
精彩评论