néné06
XLDnaute Accro
Bonjour le Forum
J'ai un dossier nommé ("Photos") qui contient des photos .JPG dans la même racine qu'une feuille excel (sur le bureau).
Mon programme Excel prend des photos dans le dossier et les affiches dans un USF.
Je suis amené a renommer certaines photos, mais je bute sur ce problème.
Voici ma routine pour afficher une image, qui fonctionne.
nom_image = Cells(CB1.ListIndex + 2, 3).Value
Img.Picture = LoadPicture(ActiveWorkbook.Path & "\Photos" & "\" & nom_image & ".jpg")
et voici mon problème
Private Sub LB7_Click()
If CB1.Value <> "" Then
ancien = CB1.Value
newnom = Application.InputBox(prompt:="Entrez le nouveau NOM")
If newnom = "Faux" Or newnom = "" Then Exit Sub
newprenom = Application.InputBox(prompt:="Entrez le nouveau Prénom")
If newprenom = "Faux" Or newprenom = "" Or newnom = "" Then Exit Sub
nbcar = Len(newprenom)
newnom = UCase(newnom)
newprenom = UCase(Left(newprenom, 1)) & LCase(Right(newprenom, nbcar - 1))
newnomprenom = UCase(newnom) + " " + newprenom
Set Ftn = Sheets("Feuil2").Range("C2:C50").Find(newnomprenom, LookIn:=xlValues, lookat:=xlWhole)
If Ftn Is Nothing Then
Cells(CB1.ListIndex + 2, 1).Value = newnom
Cells(CB1.ListIndex + 2, 2).Value = newprenom
Cells(CB1.ListIndex + 2, 3).Value = newnomprenom
'****************************************************************
'renommer photo dans dossier ("Photos")
' variable ancien doit être renommé par variable newnomprenom
'*********************************************************************
Else
reponse = MsgBox("NOM et PRENOM déja présent")
Unload Me
Exit Sub
End If
tri_noms
active_CB1
CB1.Value = newnomprenom
ecrire_excel_sur_USF
End If
End Sub
D'avance Merci !!
J'ai un dossier nommé ("Photos") qui contient des photos .JPG dans la même racine qu'une feuille excel (sur le bureau).
Mon programme Excel prend des photos dans le dossier et les affiches dans un USF.
Je suis amené a renommer certaines photos, mais je bute sur ce problème.
Voici ma routine pour afficher une image, qui fonctionne.
nom_image = Cells(CB1.ListIndex + 2, 3).Value
Img.Picture = LoadPicture(ActiveWorkbook.Path & "\Photos" & "\" & nom_image & ".jpg")
et voici mon problème
Private Sub LB7_Click()
If CB1.Value <> "" Then
ancien = CB1.Value
newnom = Application.InputBox(prompt:="Entrez le nouveau NOM")
If newnom = "Faux" Or newnom = "" Then Exit Sub
newprenom = Application.InputBox(prompt:="Entrez le nouveau Prénom")
If newprenom = "Faux" Or newprenom = "" Or newnom = "" Then Exit Sub
nbcar = Len(newprenom)
newnom = UCase(newnom)
newprenom = UCase(Left(newprenom, 1)) & LCase(Right(newprenom, nbcar - 1))
newnomprenom = UCase(newnom) + " " + newprenom
Set Ftn = Sheets("Feuil2").Range("C2:C50").Find(newnomprenom, LookIn:=xlValues, lookat:=xlWhole)
If Ftn Is Nothing Then
Cells(CB1.ListIndex + 2, 1).Value = newnom
Cells(CB1.ListIndex + 2, 2).Value = newprenom
Cells(CB1.ListIndex + 2, 3).Value = newnomprenom
'****************************************************************
'renommer photo dans dossier ("Photos")
' variable ancien doit être renommé par variable newnomprenom
'*********************************************************************
Else
reponse = MsgBox("NOM et PRENOM déja présent")
Unload Me
Exit Sub
End If
tri_noms
active_CB1
CB1.Value = newnomprenom
ecrire_excel_sur_USF
End If
End Sub
D'avance Merci !!
Dernière édition: