Option Explicit
Private Sub UserForm_Click()
ShapeImg(Me.Image1) = Feuil1.Shapes(1)
End Sub
Private Property Let ShapeImg(ByVal Img As MSForms.Image, ByVal RHS As Excel.Shape)
Rem. Inspiré d'un code de patricktoulon
Dim FicTemp As String, HImg As LongPtr, HEMF As LongPtr
ExecuteExcel4Macro "CALL(""user32"",""OpenClipboard"",""JJ"",0)"
ExecuteExcel4Macro "CALL(""user32"",""EmptyClipboard"",""J"")"
ExecuteExcel4Macro "CALL(""user32"",""CloseClipboard"",""J"")"
RHS.CopyPicture
DoEvents
Do While ExecuteExcel4Macro("CALL(""user32"",""IsClipboardFormatAvailable"",""JJC"",14)") = 0
If MsgBox("Instruction: Shapes(""" & RHS.Name & """).CopyPicture" & vbLf & _
"Le presse papier ne semble pas recevoir l'image.", _
vbRetryCancel, "Property Set ShapeImg") = vbCancel Then Exit Property
Loop
ExecuteExcel4Macro "CALL(""user32"",""OpenClipboard"",""JJ"",0)"
HImg = ExecuteExcel4Macro("CALL(""user32"",""GetClipboardData"",""JJ"",14)")
FicTemp = Environ$("UserProfile") & "\DeskTop\Temp.wmf"
HEMF = ExecuteExcel4Macro("CALL(""gdi32"",""CopyEnhMetaFileA"",""JJC""," & HImg & ",""" & FicTemp & """)")
ExecuteExcel4Macro "CALL(""gdi32"",""DeleteEnhMetaFile"",""JJ""," & HEMF & ")"
ExecuteExcel4Macro "CALL(""user32"",""CloseClipboard"",""J"")"
Img.Picture = LoadPicture(FicTemp): Kill FicTemp
End Property