je souhaite vérifier l'existence image dans un répertoire.
Les données sont définis dans un userform qui contient
le chemin du repertoire : 2 combobox (CB1 et CB2),
le nom de l'image : 1 combobox (CB3)
Je bloque totalement, je commencé un bout de code:
Code:
sub verifimage()
C = CB1.value
D = CB2.value
img = CB3.value
If FileExists('D:\DATA\" & C &"\" & D & "\" & img & ".jpg") then
msgbox "l'image existe"
else
msgbox "l'image n'existe pas"
end if
end sub
Re : Vérifier existence d'une image dans un répertoire
Bonsoir Joums,
essaye ainsi :
Code:
Sub verifimage()
Dim c As String, d As String, img As String
c = CB1.Value
d = CB2.Value
img = CB3.Value
If Dir("D:\DATA\" & c & "\" & d & "\" & img & ".jpg", vbDirectory) <> "" Then
MsgBox "l'image existe"
Else
MsgBox "l'image n'existe pas"
End If
End Sub
Re : Vérifier existence d'une image dans un répertoire
Bonsoir à tous
Avec un IIF à la place d'un End IF
Code:
Sub verifimage2()
Dim c$, d$
c = "C:\Temp" 'CB1.Value
d = "nomfichier" 'CB2.Value
img = c & "\" & d & "\" & ".jpg"
MsgBox "L'image " & IIf(Dir(img, vbDirectory) <> "", "existe.", "n'existe pas")
End Sub
Sub verifimage()
Dim c As String, d As String, img As String
c = CB1.Value
d = CB2.Value
img = CB3.Value
If Dir("D:\DATA\" & c & "\" & d & "\" & img & ".jpg", vbDirectory) <> "" Then
MsgBox "l'image existe"
Else
MsgBox "l'image n'existe pas"
End If
End Sub