注意,是VBA,不是VB,clipboard用不了的~
我现在用的是:
Dim MyData As DataObject
Dim strClip As StringSet MyData = New DataObject
MyData.GetFromClipboard
MsgBox MyData.GetText但是这样取出文字,不知道dataobject能不能转成bitmap?
然后我还想把它存成文件
谢谢啦

解决方案 »

  1.   

    Private Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Long) As Long
    Private Declare Function CloseClipboard Lib "user32" () As Long
    Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As Guid, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
    Private Const CF_BITMAP = 2
    Private Type PicBmp
        Size As Long
        Type As Long
        hBmp As Long
        hPal As Long
        Reserved As Long
    End TypePrivate Type Guid
        Data1 As Long
        Data2 As Integer
        Data3 As Integer
        Data4(0 To 7) As Byte
    End TypePrivate Sub CommandButton1_Click()
        Dim Pic As PicBmp, IPic As IPicture, IID_IDispatch As Guid
        OpenClipboard 0 'OpenClipboard
        With IID_IDispatch
            .Data1 = &H20400
            .Data4(0) = &HC0
            .Data4(7) = &H46
        End With    With Pic
            .Size = Len(Pic)
            .Type = 1
            .hBmp = GetClipboardData(CF_BITMAP)
        End With
        
        OleCreatePictureIndirect Pic, IID_IDispatch, 1, IPic
        stdole.SavePicture IPic, "c:\clipboard.bmp"
        CloseClipboard
        MsgBox "ok"
    End Sub