Usa il codice suggeritoti prima:
Siccome restituisce un valore booleano puoi usarlo senza problemi in un if: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
codice:If FileExists("c:\file.txt") Then MsgBox "Il file esiste." Else MsgBox "Il file non esiste."