- 帖子
- 17
- 主題
- 3
- 精華
- 0
- 積分
- 33
- 點名
- 0
- 作業系統
- XP SP3
- 軟體版本
- Office 2007
- 閱讀權限
- 10
- 性別
- 男
- 註冊時間
- 2011-4-30
- 最後登錄
- 2012-12-21
|
22#
發表於 2012-9-24 14:30
| 只看該作者
建議一開始就將,路徑與檔名設定成不同變數。方便之後利用。
另外
'取得路徑與檔名(不包括副檔名)
'The following function returns the filename without the extension from the file's full path:
Function FileNameNoExt(strPath As String) As String
Dim strTemp As String
strTemp = Mid$(strPath, InStrRev(strPath, "\") + 1)
FileNameNoExt = Left$(strTemp, InStrRev(strTemp, ".") - 1)
End Function
'取得完整檔名
'The following function returns the filename with the extension from the file's full path:
Function FileNameWithExt(strPath As String) As String
FileNameWithExt = Mid$(strPath, InStrRev(strPath, "\") + 1)
End Function
'取得路徑
'the following function will get the path only (i.e. the folder) from the file's ful path:
Function FilePath(strPath As String) As String
FilePath = Left$(strPath, InStrRev(strPath, "\"))
End Function |
|