Private Sub Label1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Sheets("Feuil1").Pictures.Delete
TestInsertPictureInRange
Unload Me
Sheets("Feuil1").PrintPreview
UserForm2.Show
End Sub
Sub TestInsertPictureInRange()
InsertPictureInRange Me.Label1, Range("C1:D10")
End Sub
Sub InsertPictureInRange(PictureFileName As String, TargetCells As Range)
' inserts a picture and resizes it to fit the TargetCells range
Dim p As Object, t As Double, l As Double, w As Double, h As Double
If Dir(PictureFileName) = "" Then Exit Sub
' import picture
Set p = Sheets("Feuil1").Pictures.Insert(PictureFileName)
' determine positions
With TargetCells
t = .Top + 15
l = .Left + 45
w = .Offset(0, .Columns.Count).Left + .Left
h = .Offset(.Rows.Count, 0).Top + .Top
End With
' position picture
With p
.Top = t
.Left = l
.Width = w
.Height = h
End With
Set p = Nothing
End Sub