Re : lier cellule à photos
Bonjour le forum, al1.2loin,
dans le même répertoire que le fichier et si les cellules ont le même mot que le nom des photos, ceci fonction mais en mettant les photos dans des commentaires;
Sub CommentImages()
' placer les photos dans le meme pertoire que le fichier Excel
Dim repertoire As String
Dim Echelle As Integer
Dim Lastrow As Long
Dim C As Range
Dim fichier As String
Dim Taille As Integer
repertoire = ThisWorkbook.Path & "\" & "photos\"
Echelle = 0.5
Sheets("feuille inscrits").Select
Lastrow = [D65000].End(xlUp).Row
Range("D2
😀" & Lastrow).ClearComments
For Each C In Range("nom") ' scanner zone nommée "NOM"
C.ClearComments 'effacer old commentaires
C.AddComment
C.Comment.Text Text:=CStr(C)
fichier = CStr(C.Value) & ".jpg" ' le fichier JPJ doit être le même que le mot contenu dans la cellule
If Dir(repertoire & fichier) <> "" Then
C.Comment.Shape.Fill.UserPicture repertoire & fichier
Taille = TaillePixelsImage(repertoire, fichier) ' modifier taille
C.Comment.Shape.Height = Val(Split(Taille, "x")(1))
C.Comment.Shape.Width = Val(Split(Taille, "x")(0))
C.Comment.Shape.ScaleHeight Echelle, msoFalse, msoScaleFromTopLeft
C.Comment.Shape.ScaleWidth Echelle, msoFalse, msoScaleFromTopLeft
Else
C.ClearComments
End If
Next
End Sub
Voir sur l'excellent site de J. Boisgontier (rubrique commentaires)
Formation Excel VBA JB