开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜