IfFileExist (2)



Function Exists(Path As String, File As Boolean) As Boolean
'Returns true if the file or directory passed exists...

'If the Path is a file, then File is True,

'else it is a directory.

On Error Goto Exit_Exists
If File Then
If Dir(Path) > "" Then
FileExists = True
End If
Else
If Dir(Path, vbDirectory) > "" Then
FileExists = True
End If
End If
Exit_Exists:
End Function

If FileExists (FilePath, FileName) = True Then
MsgBox "File already exists!"
Else
MsgBox "File does Not exist."
End If


(iffileexist2.html)- by Paolo Puglisi - Modifica del 25/3/2019