Please, can someone help me!
I have a userform which is called Configurator or "Config", which has some Image-Controls. These images together look like a door, because the userform is a configurator for doors. (where you can change width, height, material etc...) Mostly the "door" consists of 4 different images which make the doorframe.
Now i want to use these images on my excel-worksheet, so the user sees a picture of the door on the worksheet too.
Which method is the best way? I tried to copy & paste the images from userform to a excel worksheet, but i dont know how. I hope someone of you can show me the right way to do this!
Another way could be to somehow make a screenshot of a specific area of the userform and paste the image to the worksheet. I dont know if there is a way to do this?
Thanks for any help!
CodePudding user response:
Please, try the next way:
Let us say that pictDoor1
is the name of the picture you need to 'copy' and a new button to copy it (copyPicture
). Copy next code in its Click
event:
Private Sub copyPicture_Click()
Dim shPict As MSForms.Image, pic As MSForms.Image
Set pic = Me.pictDoor1 'use here the real name of the Image control
Set shPict = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Image.1", link:=False, _
DisplayAsIcon:=False, left:=20, top:=20, width:=pic.width, height:=pic.height).Object
shPict.Picture = pic.Picture
End Sub
It will insert an Image
control (as the picture to be copied dimensions, cut you can change them by multiplying, if need bigger ones) and place on it the necessary picture.
Then, use the newly created shape top
and left
according to the previously created width
and height
to appropriately position them...