The following function checks for the existance of a file in the current
path. Simply copy both the Sub and Function into a module and set the
parameter (parm1) to be passed to the function:-
Sub If_File_Exists()
parm1 = "Book1.xls"
If Not FileExists(parm1) Then ' Check if file/folder exists .....
MsgBox "File " & parm1 & " does not exist", vbOKCancel
Exit Sub
Else
MsgBox "File exists"
End If
End Sub
Function FileExists(fname) As Boolean
' Returns TRUE if the file exists
Dim x As String
x = Dir(fname)
If x <> "" Then
FileExists = True
Else
FileExists = False
End If
End Function
Regards,
OssieMax
> Hi all,
>
[quoted text clipped - 33 lines]
>
> Mick
Bob Phillips - 14 Sep 2007 11:20 GMT
simpler
Function FileExists(fname) As Boolean
FileExists = Dir(fname) <> ""
End Function

Signature
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my addy)
> The following function checks for the existance of a file in the current
> path. Simply copy both the Sub and Function into a module and set the
[quoted text clipped - 68 lines]
>>
>> Mick
Symbiosis - 14 Sep 2007 12:06 GMT
Thank you very much... Works a treat.
> The following function checks for the existance of a file in the current
> path. Simply copy both the Sub and Function into a module and set the
[quoted text clipped - 68 lines]
>>
>> Mick
Hi Mick
How about this:
Function ClasseurExiste(ByRef NomComplet As String) As Boolean
ClasseurExiste =
CreateObject("Scripting.FileSystemObject").GetFile(NomComplet) = Err = 0
End Function
HTH
Cordially
Pascal
> Hi all,
>
[quoted text clipped - 33 lines]
>
> Mick