Désolé mon incompétance mais les deux solution ne fonctionne pas.
Dans les deux cas, il ne fait pas la vérification et ca passe toujours.
Voici le code d'eriiic que j'ai mis dans mon fichier
Option Explicit
Sub enregistrer()
Dim nompdf As String
If IsEmpty(Range("A12")) Then MsgBox "LE NOM DU FOURNISSEUR doit être inscrit": Range("a12").Select: End
If IsEmpty(Range("o5")) Then MsgBox "LIVRÉ A doit être inscrit": Range("o5").Select: End
If IsEmpty(Range("l32")) Then MsgBox "LE NOM DU REQUÉRANT doit être inscrit": Range("l32").Select: End
If IsEmpty(Range("g16")) Then MsgBox "EXPÉDIÉ VIA doit être inscrit": Range("g16").Select: End
If IsEmpty(Range("o7")) Then MsgBox "DOSSIER EAD doit être inscrit": Range("o7").Select: End
'ici je veux que la macro valide si le nom du fichier que je vais lui donner exsiste déja dans le répertoire. Si oui la macro cesse avec un msgbox.
nompdf = "\\nasead01\administration\documents\a\" & Range("B2").Value & " " & Range("r2") & "-" & Range("aa2") & " " & Range("o5")
If Dir(nompdf) = "" Then
' fich n'existe pas
ThisWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=nompdf & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Range("o5:v8") = ""
Range("A12") = "Vitrerie Commercial"
Range("a21:w31") = ""
Range("l3") = ""
Range("q34") = ""
Else
' fich existe
MsgBox "Le fichier Existe déjà": End
End If
Exit Sub
End Sub