Vérifier si le fichier existe en utilisant VBA
Vérifier si le fichier existe en utilisant VBA
Comment vérifier si un fichier existe en VBA ?
Re: Vérifier si le fichier existe en utilisant VBA
**Méthode 1 : Fonction Dir**
```vba
If Dir("C:\chemin\fichier.txt") <> "" Then
MsgBox "Le fichier existe"
End If
```
**Méthode 2 : FileSystemObject**
```vba
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("C:\chemin\fichier.txt") Then
MsgBox "Le fichier existe"
End If
```
```vba
If Dir("C:\chemin\fichier.txt") <> "" Then
MsgBox "Le fichier existe"
End If
```
**Méthode 2 : FileSystemObject**
```vba
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("C:\chemin\fichier.txt") Then
MsgBox "Le fichier existe"
End If
```