- 帖子
- 12
- 主題
- 1
- 精華
- 0
- 積分
- 50
- 點名
- 0
- 作業系統
- Windows
- 軟體版本
- Xp
- 閱讀權限
- 20
- 註冊時間
- 2017-12-26
- 最後登錄
- 2019-5-21
|
4#
發表於 2018-1-2 17:36
| 只看該作者
回復 3# prin.huang
Sub P_Sample004()
Dim myFileName As String
myFileName = Application.InputBox(Prompt:= _
"請輸入檔案名稱、資料夾名稱的完整路徑", Title:="確認存在")
If Len(Dir(myFileName, vbDirectory)) > 0 Then
If (GetAttr(myFileName) And vbDirectory) = vbDirectory Then
MsgBox "所指定之資料夾存在。"
Else
MsgBox "所指定之檔案存在。"
End If
Else
MsgBox "所指定之檔案或是目錄不存在。"
End If
End Sub
Sub P_Sample003()
Dim myPath As String
Dim myFileName As String
Dim i As Long
myPath = ThisWorkbook.Path & "\" '任意的資料夾
myFileName = Dir(myPath, 0)
Do While Len(myFileName) > 0
Debug.Print myPath & myFileName
myFileName = Dir()
Loop
End Sub |
|