AW: Bild aus Userform in Zelle
09.04.2007 23:55:03
Nepumuk
Hi ihr zwei,
so geht's auch:
' **********************************************************************
' Modul: UserForm1 Typ: Userform
' **********************************************************************
Option Explicit
Private Declare Function CopyImage Lib "user32.dll" ( _
ByVal handle As Long, _
ByVal imageType As Long, _
ByVal newWidth As Long, _
ByVal newHeight As Long, _
ByVal lFlags As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function OpenClipboard Lib "user32.dll" ( _
ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib "user32.dll" () As Long
Private Declare Function CloseClipboard Lib "user32.dll" () As Long
Private Declare Function SetClipboardData Lib "user32.dll" ( _
ByVal wFormat As Long, _
ByVal hMem As Long) As Long
Private Declare Function DeleteObject Lib "gdi32.dll" ( _
ByVal hObject As Long) As Long
Private Const IMAGE_BITMAP = 0&
Private Const LR_COPYRETURNORG = &H4
Private Const GC_CLASSNAMEMSEXCEL = "XLMAIN"
Private Const CF_BITMAP = 2&
Private Sub CommandButton1_Click()
Dim lngTempPicture As Long
lngTempPicture = CopyImage(Me.Image1.Picture, _
IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG)
If lngTempPicture <> 0 Then
OpenClipboard FindWindow(GC_CLASSNAMEMSEXCEL, Application.Caption)
EmptyClipboard
SetClipboardData CF_BITMAP, lngTempPicture
CloseClipboard
ActiveSheet.Paste
DeleteObject lngTempPicture
End If
End Sub
Gruß
Nepumuk