I trying to create a file ck in VBA. I want to use a if statment to ck to see if a file exist then do what ever. Can somebody help
Printable View
I trying to create a file ck in VBA. I want to use a if statment to ck to see if a file exist then do what ever. Can somebody help
IF FileExists(lsFileName) Then
'DO stuff the file was found
Else
'Do something else the file wasn't foudn
END IF
Public Function FileExists(pstrFileName As String) As Boolean
FileExists = False 'set the return value by default
If Len(Dir(pstrFileName)) > 0 Then 'Dir will return the filename if the file is found
FileExists = True 'Return true the file exists
End If
End Function
Thanks for the help it works