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:

  1. Anonymous4:37 AM

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

    ReplyDelete
  2. Anonymous11:57 PM

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

    ReplyDelete
  3. wow! thanks a lot!

    ReplyDelete
  4. Anonymous2:25 AM

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

    ReplyDelete
  5. Anonymous9:51 AM

    Just what I needed! Thanks man

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

    ReplyDelete
  7. Anonymous12:58 AM

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

    ReplyDelete
  8. Or more simply try: =CELL("filename")

    ReplyDelete
  9. Anonymous8:24 PM

    thanks for this information

    ReplyDelete