Dim fs As Object Dim getphoto As String getphoto="C:\123\...." '判斷圖片路徑是否有效 If getphoto <> "" Then Set fs = CreateObject("Scripting.FileSystemObject") If (fs.fileexists(getphoto)) Then get_photopath = getphoto Else get_photopath = "" End If Set fs = Nothing End If
用dir if dir$(路径,vbnormal)="" then msgbox("文件不存在") exit sub else msgbox("文件存在") end if
Dim getphoto As String
getphoto="C:\123\...."
'判斷圖片路徑是否有效
If getphoto <> "" Then
Set fs = CreateObject("Scripting.FileSystemObject")
If (fs.fileexists(getphoto)) Then
get_photopath = getphoto
Else
get_photopath = ""
End If
Set fs = Nothing
End If
if dir$(路径,vbnormal)="" then
msgbox("文件不存在")
exit sub
else
msgbox("文件存在")
end if