+ Reply to Thread
Results 1 to 5 of 5

Copy picture from image control

Hybrid View

  1. #1
    Ian
    Guest

    Copy picture from image control

    I have an Excel addin that contains an image control on a userform. When
    the addin is run, I would like to copy the picture from the image control to
    a worksheet. What I would like to do is ActiveSheet.pictures.add
    Image1.Picture, but of course this doesn't work.

    Any suggestions?



  2. #2
    Tom Ogilvy
    Guest

    Re: Copy picture from image control

    Where did the image control get the picture - it is usually from a file -
    couldn't you import the image from the file?

    --
    Regards,
    Tom Ogilvy

    "Ian" <notreadingyourcrap@hotmail.com> wrote in message
    news:ufL0j3sCFHA.3100@TK2MSFTNGP09.phx.gbl...
    > I have an Excel addin that contains an image control on a userform. When
    > the addin is run, I would like to copy the picture from the image control

    to
    > a worksheet. What I would like to do is ActiveSheet.pictures.add
    > Image1.Picture, but of course this doesn't work.
    >
    > Any suggestions?
    >
    >




  3. #3
    Ian
    Guest

    Re: Copy picture from image control

    Yes, but then I would need to distribute the file with the addin, which I
    don't want to do.

    "Tom Ogilvy" <twogilvy@msn.com> wrote in message
    news:#Y$DwOuCFHA.3424@TK2MSFTNGP14.phx.gbl...
    > Where did the image control get the picture - it is usually from a file -
    > couldn't you import the image from the file?
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Ian" <notreadingyourcrap@hotmail.com> wrote in message
    > news:ufL0j3sCFHA.3100@TK2MSFTNGP09.phx.gbl...
    > > I have an Excel addin that contains an image control on a userform.

    When
    > > the addin is run, I would like to copy the picture from the image

    control
    > to
    > > a worksheet. What I would like to do is ActiveSheet.pictures.add
    > > Image1.Picture, but of course this doesn't work.
    > >
    > > Any suggestions?
    > >
    > >

    >
    >




  4. #4
    Michel Pierron
    Guest

    Re: Copy picture from image control

    Hi ,
    May be:

    Private Declare Function OpenClipboard& _
    Lib "user32" (ByVal hwnd As Long)
    Private Declare Function EmptyClipboard _
    Lib "user32" () As Long
    Private Declare Function SetClipboardData& _
    Lib "user32" (ByVal wFormat&, ByVal hMem&)
    Private Declare Function CloseClipboard& _
    Lib "user32" ()
    Private Declare Function DestroyIcon& _
    Lib "user32" (ByVal hIcon&)

    Sub ImageCopy()
    Dim iPic As StdPicture, hCopy&
    Set iPic = UserForm1.Image1.Picture
    OpenClipboard 0&: EmptyClipboard
    hCopy = SetClipboardData(2, iPic.handle)
    CloseClipboard
    If hCopy Then
    ActiveSheet.Cells(1, 1).Select
    ActiveSheet.Paste
    ' Save image on disk:
    'SavePicture iPic, "c:\Recup.bmp"
    End If
    DestroyIcon iPic.handle
    Set iPic = Nothing
    End Sub

    Regards,
    MP

    "Ian" <notreadingyourcrap@hotmail.com> a écrit dans le message de
    news:ufL0j3sCFHA.3100@TK2MSFTNGP09.phx.gbl...
    > I have an Excel addin that contains an image control on a userform. When
    > the addin is run, I would like to copy the picture from the image control

    to
    > a worksheet. What I would like to do is ActiveSheet.pictures.add
    > Image1.Picture, but of course this doesn't work.
    >
    > Any suggestions?
    >
    >



  5. #5
    Ian
    Guest

    Re: Copy picture from image control

    Excellent! That is exactly what I needed. Thank you.

    "Michel Pierron" <michel.pierron@free.fr> wrote in message
    news:O4AUuSvCFHA.4020@TK2MSFTNGP14.phx.gbl...
    > Hi ,
    > May be:
    >
    > Private Declare Function OpenClipboard& _
    > Lib "user32" (ByVal hwnd As Long)
    > Private Declare Function EmptyClipboard _
    > Lib "user32" () As Long
    > Private Declare Function SetClipboardData& _
    > Lib "user32" (ByVal wFormat&, ByVal hMem&)
    > Private Declare Function CloseClipboard& _
    > Lib "user32" ()
    > Private Declare Function DestroyIcon& _
    > Lib "user32" (ByVal hIcon&)
    >
    > Sub ImageCopy()
    > Dim iPic As StdPicture, hCopy&
    > Set iPic = UserForm1.Image1.Picture
    > OpenClipboard 0&: EmptyClipboard
    > hCopy = SetClipboardData(2, iPic.handle)
    > CloseClipboard
    > If hCopy Then
    > ActiveSheet.Cells(1, 1).Select
    > ActiveSheet.Paste
    > ' Save image on disk:
    > 'SavePicture iPic, "c:\Recup.bmp"
    > End If
    > DestroyIcon iPic.handle
    > Set iPic = Nothing
    > End Sub
    >
    > Regards,
    > MP
    >
    > "Ian" <notreadingyourcrap@hotmail.com> a écrit dans le message de
    > news:ufL0j3sCFHA.3100@TK2MSFTNGP09.phx.gbl...
    > > I have an Excel addin that contains an image control on a userform.

    When
    > > the addin is run, I would like to copy the picture from the image

    control
    > to
    > > a worksheet. What I would like to do is ActiveSheet.pictures.add
    > > Image1.Picture, but of course this doesn't work.
    > >
    > > Any suggestions?
    > >
    > >

    >




+ 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