tags:

views:

25

answers:

2

I'm using vba in Excel 2007 to read a spreadsheet and modify it's contents. I need to save the results with a name that is similar to the original file, but with some alterations.

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

Thanks in advance.

+2  A: 

It depends, here are two possibilities:

Debug.Print ActiveWorkbook.Name

For Each wk In Workbooks
    Debug.Print wk.Name
Next
Remou
That works perfectly. Thanks for answering!
Jacob Winn
+2  A: 

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

Michael
While your answer is correct I accepted the other answer only because it is what I used. That's why I upvoted your answer as well. Thanks for the quick response.
Jacob Winn
Hey, whatever gets the job done!
Michael