Un modo per conoscere se esiste un file:

Function EsisteFile(NomeFile As String) As Boolean
On Error Resume Next
EsisteFile = (GetAttr(NomeFile) And vbDirectory) = 0
End Function


Da richiamare nel seguente modo:
Dim EsisteFile As Boolean
EsisteFile = EsisteFile("C:/pincopallino.txt")
If EsisteFile = True Then
MsgBox"Il file esiste"
End If
If EsisteFile = False Then
MsgBox "Il file non esiste"
End If


Invece per e directory
Function EsisteDir(NomeDir As String) As Boolean
On Error Resume Next
EsisteDir = GetAttr(NomeDir) And vbDirectory
End Function


Da utilizzare cosi:

Dim EsisteDir As Boolean
EsisteDir = EsisteDir("C:/pincopallino")
If EsisteDir = True Then
MsgBox"La directory esiste"
End If
If EsisteDir = False Then
MsgBox "La directory non esiste"
End If


by gius