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
| Sub image_dans_clipboard()
'on copie la selection dans le clipboard
Sheets("DESSIN").Shapes(élément_fenêtre).CopyPicture xlScreen, xlBitmap 'copie la selection dans le clipboard (xlBitmap:(.bmp, .jpg, .gif))
'prend l'image dans le cliboard
Dim hCopy&: OpenClipboard 0&
hCopy = CopyImage(GetClipboardData(2), 0, 0, 0, &H8)
CloseClipboard
If hCopy = 0 Then Exit Sub
Const IPictureIID = "{7BF80981-BF32-101A-8BBB-00AA00300CAB}"
Dim iPic As IPicture, tIID As GUID, tPICTDEST As PICTDESC, Ret As Long
Ret = IIDFromString(StrConv(IPictureIID, vbUnicode), tIID)
If Ret Then Exit Sub
With tPICTDEST
.cbSize = Len(tPICTDEST)
.picType = 1 ' "1" xlBMP - "2" xlWMF - "3" xlWPG
.hImage = hCopy
End With
Ret = OleCreatePictureIndirect(tPICTDEST, tIID, 1, iPic)
If Ret Then Exit Sub
' ********************************
' Crée un controle dans l'Userform
Dim Obj As Control
Set Obj = croquis.Controls.Add("Forms.Image.1")
' Affiche l'image dans l'UserForm
With Obj
.Name = élément_fenêtre
.Picture = iPic
.PictureSizeMode = fmPictureSizeModeStretch 'fmPictureSizeModeZoom
.BackStyle = fmBackStyleTransparent
.Top = Top_élément_fenêtre
.Left = Left_élément_fenêtre
.Height = Height_élément_fenêtre
.Width = Width_élément_fenêtre
.BorderStyle = fmBorderStyleNone
.BackStyle = fmBackStyleTransparent
End With
Set iPic = Nothing
VidePP
End Sub |
Partager