Usa il codice suggeritoti prima:
codice:
Public Function FileExists(ByVal PathAndFileName As String) As Boolean
On Error Resume Next
FileExists = (GetAttr(PathAndFileName) And vbDirectory) = 0
On Error goto 0
End Function
Siccome restituisce un valore booleano puoi usarlo senza problemi in un if:
codice:
If FileExists("c:\file.txt") Then MsgBox "Il file esiste." Else MsgBox "Il file non esiste."