How to get the excel file name / path in VBA

前端 未结 6 1654
粉色の甜心
粉色の甜心 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 16:58

    this is a simple alternative that gives all responses, Fullname, Path, filename.

    Dim FilePath, FileOnly, PathOnly As String
    
    FilePath = ThisWorkbook.FullName
    FileOnly = ThisWorkbook.Name
    PathOnly = Left(FilePath, Len(FilePath) - Len(FileOnly))
    

提交回复
热议问题