先把图象clipboard.setdata然后调用CommandBarButton.pasteface

解决方案 »

  1.   

    Unl:
     clipboard.setdata (LoadPicture("d:\ms.bmp")) //can not pass, have runtime error
     cbCmdBar.PasteFace i am the beginer of DBA, can you write out the source code? thank you
              YYboy
      

  2.   

    i can not found clipboard class
      

  3.   

    参考一下:Private Sub CommandButton1_Click()set picture = loadpicture("..filename...")Dim lhwnd As Long
    lhwnd = FindWindow(vbNullString, "UserForm1")Dim hScrDC As Long
    hScrDC = GetDC(lhwnd)Dim hMemDC As Long
    hMemDC = CreateCompatibleDC(hScrDC)Dim xScrn As Integer
    Dim yScrn As Integer
    xScrn = Width / 15
    yScrn = Height / 15Dim hBitmap As Long
    hBitmap = CreateCompatibleBitmap(hScrDC, xScrn, yScrn)
    Dim hOldmap As Long
    hOldmap = SelectObject(hMemDC, hBitmap)
    BitBlt hMemDC, 0, 0, xScrn, yScrn, hScrDC, 0, 0, SRCCOPY
    hBitmap = SelectObject(hMemDC, hOldmap)
    DeleteDC hScrDC
    DeleteDC hMemDC
    OpenClipboard lhwnd
    EmptyClipboard
    SetClipboardData CF_BITMAP, hBitmap
            CloseClipboardApplication.CommandBars(3).Controls(1).PasteFace
    End Sub