How to get the excel file name / path in VBA

前端 未结 6 1703
粉色の甜心
粉色の甜心 2021-01-07 15:58

Say, I\'m writing a VBA inside my excel file sample.xls. Now I want to get the full path of sample.xls in my VBA. How do I do it?

6条回答
  •  青春惊慌失措
    2021-01-07 17:03

    There is a universal way to get this:

    Function FileName() As String
        FileName = Mid(Application.Caption, 1, InStrRev(Application.Caption, "-") - 2)
    End Function
    

提交回复
热议问题