+ Reply to Thread
Results 1 to 7 of 7

Copy & paste image from UserForm (repost)

  1. #1
    Paul Martin
    Guest

    Copy & paste image from UserForm (repost)

    Hi all


    Is there an easy way to enable cut & paste from an image on a UserForm
    (to another app, say Word). I have an Image control that displays a
    chart GIF. I would like the user to be able to right-click and cut &
    paste in the usual Windows manner. Are there some APIs that enable
    this?

    I have received a post that enables copy to Office Clipboard, but I
    want to copy to the Windows clipboard.

    Thanks in advance


    Paul Martin
    Melbourne, Australia


  2. #2
    Paul Martin
    Guest

    Re: Copy & paste image from UserForm (repost)

    For the benefit of others, I have received information elsewhere that
    appears to answer my question (I haven't tested it yet).

    Thanks to Stephen Bullen who has directed me to this URL at ****'s
    Clicks:
    <www.*****-blog.com/archives/2004/12/07/using-copypaste-in-userforms>

    Regards

    Paul Martin
    Melbourne, Australia


  3. #3
    Michel Pierron
    Guest

    Re: Copy & paste image from UserForm (repost)

    Hi Paul,
    See "Capture part of screen" post of benitAAvi.
    MP

    "Paul Martin" <[email protected]> a écrit dans le message de news:
    [email protected]...
    > Hi all
    >
    >
    > Is there an easy way to enable cut & paste from an image on a UserForm
    > (to another app, say Word). I have an Image control that displays a
    > chart GIF. I would like the user to be able to right-click and cut &
    > paste in the usual Windows manner. Are there some APIs that enable
    > this?
    >
    > I have received a post that enables copy to Office Clipboard, but I
    > want to copy to the Windows clipboard.
    >
    > Thanks in advance
    >
    >
    > Paul Martin
    > Melbourne, Australia
    >




  4. #4
    Paul Martin
    Guest

    Re: Copy & paste image from UserForm (repost)

    Hi Michel

    Thanks, but the code at
    <http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.excel.programming&mid=bedaf42e-e33b-44a4-97f0-b487be84a03d&sloc=en-us>
    appears to do the same as Atl-PrtScr, copying the UserForm. I want to
    copy just the Image on the form, not the whole form.

    Regards

    Paul Martin
    Melbourne, Australia


  5. #5
    Michel Pierron
    Guest

    Re: Copy & paste image from UserForm (repost)

    Yes Paul, you are right.
    In what the first procedure doesn't give you satisfaction?
    If it is the presence of the Office Clipboard, you can mask it afterwards
    immediately.

    Option Explicit
    Private Declare Function _
    OpenClipboard& Lib "user32" (ByVal hwnd&)
    Private Declare Function _
    EmptyClipboard& Lib "user32" ()
    Private Declare Function _
    SetClipboardData& Lib "user32" _
    (ByVal wFormat&, ByVal hMem&)
    Private Declare Function _
    CloseClipboard& Lib "user32" ()

    Private Sub CommandButton1_Click()
    On Error Resume Next
    Application.CommandBars.FindControl(1, 809).Execute
    Dim hCopy&
    OpenClipboard 0&: EmptyClipboard
    hCopy = SetClipboardData(2, Me.Image1.Picture.handle)
    CloseClipboard
    Application.CommandBars.FindControl(1, 5746).Execute
    ' Test procedure
    If hCopy Then PasteInWord
    End Sub

    Sub PasteInWord()
    With CreateObject("Word.Application")
    ..Visible = True
    ..Documents.Add
    ..Selection.Paste
    End With
    End Sub

    Regards,
    MP


    "Paul Martin" <[email protected]> a écrit dans le message de news:
    [email protected]...
    > Hi Michel
    >
    > Thanks, but the code at
    >

    <http://msdn.microsoft.com/newsgroups...t.public.excel
    ..programming&mid=bedaf42e-e33b-44a4-97f0-b487be84a03d&sloc=en-us>
    > appears to do the same as Atl-PrtScr, copying the UserForm. I want to
    > copy just the Image on the form, not the whole form.
    >
    > Regards
    >
    > Paul Martin
    > Melbourne, Australia
    >




  6. #6
    Paul Martin
    Guest

    Re: Copy & paste image from UserForm (repost)

    Hi Michel

    Thanks for your persistence in offering ideas, but it's not the
    solution I'm after.

    Regards

    Paul Martin
    Melbourne, Australia


  7. #7
    Paul Martin
    Guest

    Re: Copy & paste image from UserForm (repost)

    Michel

    I have tried your code and it works fine in Excel 2003 but fails in
    Excel 2000, at Application.CommandBars.FindControl.

    Any suggestions?

    Private Const OFFICE_CLIPBOARD = 809

    Private Sub CopyImageToOfficeClipboard()
    Dim hCopy As Long

    On Error GoTo ExitSub
    Application.CommandBars.FindControl(, OFFICE_CLIPBOARD).Execute
    OpenClipboard 0&
    EmptyClipboard
    hCopy = SetClipboardData(2, imgLargeChart.Picture.Handle)
    CloseClipboard

    ExitSub:

    End Sub



    Regards

    Paul Martin
    Melbourne, Australia


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1