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 Inputs: FilePath = String: Any valid directory path FileName = String: Valid file name in FilePath Directory. Returns:True = File exists False = File does Not exist |