![]() |
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? |
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" wrote in message ... 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? |
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" a écrit dans le message de ... 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? |
Copy picture from image control
Excellent! That is exactly what I needed. Thank you.
"Michel Pierron" wrote in message ... 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" a écrit dans le message de ... 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? |
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" wrote in message ... 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" wrote in message ... 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? |
All times are GMT +1. The time now is 10:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com