Vérification si fichier existe

Bonjour,

j'ai une macro qui vise à verifier si presence ou non de fichier

pgaFileName = chemin & "\Projects_Library\" & Prj(j, 3) & "-" & Prj(j, 1) & "\Contracts\Grant Agreement - GAP-" & Project_Ref & ".pdf"

pgaFileExists = Dir(pgaFileName)
cela fonctionne bien

seulement voila pgaFileName pourrait désormais avoir diffèrent nom

pgaFileName = chemin & "\Projects_Library\" & Prj(j, 3) & "-" & Prj(j, 1) & "\Contracts\Grant Agreement - GAP-" & Project_Ref & ".pdf"

ou

pgaFileName = chemin & "\Projects_Library\" & Prj(j, 3) & "-" & Prj(j, 1) & "\Contracts\Grant Agreement-" & Project_Ref & "-" & Prj(j, 3) & ".pdf"

comment introduire cette notion de ou cela dans

pgaFileExists 

merci par avance

Bonjour

Si le 1er ne donne rien, rappeler pageFileExist sur le second...

Bonjour,

j'ai tenté mais ne doit pas procéder correctement

pgaFileName = chemin & "\Projects_Library\" & Prj(j, 3) & "-" & Prj(j, 1) & "\Contracts\Grant Agreement - GAP-" & Project_Ref & ".pdf"
pgaFileName2 = chemin & "\Projects_Library\" & Prj(j, 3) & "-" & Prj(j, 1) & "\Contracts\Grant Agreement-" & Project_Ref & "-" & Prj(j, 3) & ".pdf"
pgaFileName3 = chemin & "\Projects_Library\" & Prj(j, 3) & "-" & Prj(j, 1) & "\Contracts\GA.pdf"

pgaFileExists = Dir(pgaFileName)
pgaFileExists = Dir(pgaFileName2)
pgaFileExists = Dir(pgaFileName3)

If (pgaFileExists <> "") Then
                   Sheets("Lacks").Range("V" & k) = "1"
                   Else
                   Sheets("Lacks").Range("V" & k) = "0"
                   'Grant Agreement
                    End If

car cela ne marche pas

Bonjour,

Hello Chris, j'espère que tout va bien pour toi :)

Et comme ça ?

pgaFileName = chemin & "\Projects_Library\" & Prj(j, 3) & "-" & Prj(j, 1) & "\Contracts\Grant Agreement - GAP-" & Project_Ref & ".pdf"
pgaFileName2 = chemin & "\Projects_Library\" & Prj(j, 3) & "-" & Prj(j, 1) & "\Contracts\Grant Agreement-" & Project_Ref & "-" & Prj(j, 3) & ".pdf"
pgaFileName3 = chemin & "\Projects_Library\" & Prj(j, 3) & "-" & Prj(j, 1) & "\Contracts\GA.pdf"

Sheets("Lacks").Range("V" & k) = "0"
if Dir(pgaFileName) <> "" then 
    Sheets("Lacks").Range("V" & k) = "1"
    Else : if Dir(pgaFileName2) <> "" then
        Sheets("Lacks").Range("V" & k) = "1"
        Else : if Dir(pgaFileName3) <> "" then Sheets("Lacks").Range("V" & k) = "1"
    end if
end if

non testé, et je n'ai pas fait de VBA depuis un petit moment, possible que je sois rouillé :)

Merci 21Formatic

Oui cela fonctionne très bien merci à vous

Rechercher des sujets similaires à "verification fichier existe"