I am looking to view an image from a worksheet in an image control in a user form.
This image will change depending on the value in the drop-down list. I inserted (Using: Insert → Pictures) a couple of images in the "Sheet1" of my book and named them "Picture1" and "Picture2".
I created below UserForm:
Form http://im56.gulfup.com/msKyqi.png
And this is the code I'm trying to use to download images from a worksheet, but unfortunately it is not working right now.
Private Sub ComboBox1_Change()
UserForm1.Image1.Picture = LoadPicture(Worksheets("Sheet1").Shapes(ComboBox1.Value))
End Sub
Private Sub UserForm_Initialize()
UserForm1.ComboBox1.Clear
UserForm1.ComboBox1.AddItem "Picture1"
UserForm1.ComboBox1.AddItem "Picture2"
UserForm1.ComboBox1.Value = "Picture1"
UserForm1.Image1.Picture = LoadPicture(Worksheets("Sheet1").Shapes(ComboBox1.Value))
End Sub
Every time I run this code, I get the following error:
Error http://im43.gulfup.com/YoWvTp.png
Please inform.
source
share