Thursday, July 06, 2006

Excel: Get Filename of Current Workbook

Here is a quick Excel tip. There is an easy way to get the name of the currently open file/workbook using VBA. Demonstration code is below:

Sub displayName()
    MsgBox ActiveWorkbook.FullName, vbOKOnly ‘Display full filename with path
    MsgBox ActiveWorkbook.Name, vbOKOnly ‘Display filename only, no path
End Sub

9 comments:

Anonymous said...

just what I was looking for. Thanks a lot...

Anonymous said...

Perfect! - exactly what I needed. Thank you very much

ervee04 said...

wow! thanks a lot!

Steve H said...

That was exactly what I wanted... and not buried in a 1000 word article, excellent.

Jasmine said...

Just what I needed! Thanks man

BigCreep said...

Exactly what I needed!! Just excellent work, man. Best. Blog. Ever.

Anonymous said...

Just what I needed ! :)
thx 4 this :)

Tom said...

Or more simply try: =CELL("filename")

Anonymous said...

thanks for this information