copy userform image

orsm6

Active Member
Joined
Oct 3, 2012
Messages
496
Office Version
  1. 365
Platform
  1. Windows
Hi all - i came across the following code - it helps me copy an image (picture) from my user form to a spreadsheet. I have now found that I am unable to select the picture on the sheet and cannot even delete it. My end goal is to use the user form and then transfer all the values into a spreadsheet that is set up as a printable template (including with the images)

is there a better way to do it other than with this code?
I would really like to be able to put any picture type in there... at least .png as well as .jpg. but if that isn't possible then no stress.

Code:
Sub imagetopcr()
Dim shapeImage As OLEObject
    With Worksheets("PCR Form")
    Set shapeImage = .OLEObjects.Add(ClassType:="Forms.Image.1", _
    Left:=.Cells(14, "h").Top, _
    Top:=.Cells(14, "h").Top, _
    Width:=Me.Image1.Width, _
    Height:=Me.Image1.Height)
End With

With shapeImage
    .Object.PictureSizeMode = 3
    .Object.Picture = Me.Image1.Picture
End With

End Sub


EDIT: i now find that I have to be in "Design Mode" to allow me to delete the image from the sheet.
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
If the Image in the USerForm is from an image file, could you not place the same image file into the worksheet?
 
Upvote 0
If the Image in the USerForm is from an image file, could you not place the same image file into the worksheet?
What you are saying makes sense, and i thought that it would. the code i use sends the userform image to H16, so I would have thought it'd just replace that which was there, but it doesn't. It actually put the image next to the one that was still there. I have managed to find a code on here that loops through and removes linked or embedded OLE objects....

The way the image copies over isn't a huge concern, it was more that i though that i couldn't delete it. So now that i have this macro i can run an open workbook event to clear out the template before the userform opens up.
 
Upvote 0

Forum statistics

Threads
1,214,535
Messages
6,120,093
Members
448,944
Latest member
SarahSomethingExcel100

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top