这可用下列语句进行判断
Dir([pathname],[Attributes as VbFileAttribute=vbNormal]) As String
解释: pathname:文件的绝对路径;
Attributes:文件的属性。
“[]”内为可选项。dir(file)=""表示文件不存在,dir(file)<>""表示文件存在。
例如判断c:wpswinwps.exe是否存在,如存在,就调用它,可用下列语句:
if dir("c:wpswinwps.exe")<>"" then
shell "c:wpswinwps.exe"
end if
if dir(app.path & "\abc.txt")="" then
'不存在
else
'存在
end if
if dir(app.path & "\abc.txt")<>"" then
MsgBox app.path & "\abc.txt")<>"" & "文件存在 "
else
MsgBox app.path & "\abc.txt")<>"" & "文件不存在 "
end if
dir(你的文件路径)>0 表示文件存在,否则不存在
Dim fsoTest As New FileSystemObject
If fsoTest.FolderExists(App.Path & "\abc.txt") = True Then
MsgBox "文件存在 "
Else
MsgBox "不存在 "
End If