Excel VBA: Regular Expression - get file name

后端 未结 5 1690
轮回少年
轮回少年 2021-01-25 07:30

How do I get just filename (without path and extension)
like \"MyFileName\"
from the following full path?
C:\\A_B\\C.D\\E_\\F0123456789\\G\\MyFileName.txt

5条回答
  •  没有蜡笔的小新
    2021-01-25 07:53

    If it's a real file that you have access to, you can use Dir

    sFileOnly = Dir(sPathAndFile)
    

    If it's not a real file or you don't have access to it, this will return an empty string.

提交回复
热议问题