• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copying and pasting an Excel Shape object to a VBA user form image

jjosa

New Member
I'm trying to copy and past an Excel Shape object to a VBA user form image but can't seem to figure it out.


The code I have so far is this:


Private Sub CommandButton4_Click()

Dim pic As Shape


Set pic = ActiveSheet.Shapes(ActiveSheet.Shapes.Count)

pic.CopyPicture xlScreen, xlBitmap

End Sub
 
Hi, jjosa!


Never been faced with such issue, so let me think while writing.


You got the image in the clipboard yet, first step ok.


Now how do you move that image to an image control on a userform? The only way is thru the Picture property and the LoadPicture statement that needs a file name with full path.

So the problem is how to generate that file... There are APIs (application program interfaces) that handle clipboard contents... Let me see...


I found them, but why reinventing the wheel? Give a look at this link:

http://www.mrexcel.com/forum/showthread.php?t=233108


But it doesn't work (it actually hangs badly) in Excel 2010. Maybe it helps you, if I find anything else (or the time to build access to clipboard and copy image) I'll post again.


Good luck.


Regards!


PS: BTW, I'd recommend you to read the three first green sticky topics at this forums main page. There you'll find general guidelines about how this site and community operates (introducing yourself, posting files, netiquette rules, and so on).

Among them you're prompted to perform searches within this site before posting, because maybe your question had been answered yet.

Feel free to play with different keywords so as to be led thru a wide variety of articles and posts, and if you don't find anything that solves your problem or guides you towards a solution, well, come back here, tell us what you've done, consider uploading a sample file as recommended, and somebody surely will read your post and help you.
 
The file below has some ideas on this topic.. It is not functioning fully.
Has some problem with the userform layout redraw when controls are clicked.
The Images work great.. the command buttons sick.. the labels failing.
If useful use any parts you like .. If you find the LOST ??? problem let all know
 

Attachments

  • ShapetoFormChandoo.xls
    202 KB · Views: 77
If you only want a DIY solution Copy the shape
go to the editor get the form ... control to put Picture on
go to properties ... Picture .. There Ctrl V to paste
and it is there..
 
Back
Top