1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| Private Sub UserForm_Initialize()
Set f = Sheets("BDD")
Me.ImageList1.ImageHeight = 60
Me.ImageList1.ImageWidth = 60 / 1.2
répertoirePhoto = ThisWorkbook.Path & "/photos/" ' adapter
With Me.ListView1
With .ColumnHeaders
.Clear
.Add , , "Nom", 80
End With
ligne = 1
.Gridlines = True
.View = lvwReport
For Each c In f.Range("B9:B" & f.[B65000].End(xlUp).Row)
.ListItems.Add , , c
If Dir(répertoirePhoto & c & ".jpg") <> "" Then
Me.ImageList1.ListImages.Add , "Img" & ligne, LoadPicture(répertoirePhoto & c & ".jpg")
Set Me.ListView1.SmallIcons = Me.ImageList1
Me.ListView1.ListItems(ligne).SmallIcon = "Img" & ligne
End If
ligne = ligne + 1
Next c
End With
End Sub
Private Sub ListView1_Click()
nom = Me.ListView1.SelectedItem
ActiveCell = nom
For Each s In ActiveSheet.Shapes
If s.Type = 13 Then
If s.TopLeftCell.Address = ActiveCell.Offset(0, 1).Address Then s.Delete
End If
Next s
répertoirePhoto = ThisWorkbook.Path & "/photos/"
Set img = ActiveSheet.Pictures.Insert(répertoirePhoto & nom & ".jpg")
img.Left = ActiveCell.Offset(, 1).Left + 1
img.Top = ActiveCell.Offset(, 1).Top + 1
ech = 0.75
img.Height = img.Height * ech
img.Width = img.Width * ech
End Sub |