Sub Trombine()
repertoire = ThisWorkbook.Path & "\"
For Each c In Range("A2", [A65000].End(xlUp))
c.ClearComments
c.AddComment
c.Comment.Text Text:=CStr(c)
fichier = CStr(c.Value) & ".jpg"
If Dir(repertoire & fichier) <> "" Then
c.Comment.Shape.Fill.UserPicture repertoire & fichier
taille = TaillePixelsImage(repertoire, fichier)
c.Comment.Shape.Height = Val(Split(taille, "x")(1))
c.Comment.Shape.Width = Val(Split(taille, "x")(0))
c.Comment.Shape.ScaleHeight 0.8, msoFalse, msoScaleFromTopLeft
c.Comment.Shape.ScaleWidth 0.8, msoFalse, msoScaleFromTopLeft
End If
Next
End Sub
Function TaillePixelsImage(repertoire, fichier)
Set myShell = CreateObject("Shell.Application")
Set myFolder = myShell.Namespace(repertoire)
Set myFile = myFolder.Items.Item(fichier)
TaillePixelsImage = myFolder.GetDetailsOf(myFile, 26)
End Function