PDA

View Full Version : Solved: LoadPicture Function in Powerpoint Userform



heatdav
07-24-2012, 12:45 AM
Hi. I've created a very simple userform that only contains an image (image1) and a checkbox (checkbox1). I want to load and unload a picture via a checkbox. I wrote the following code, which works fine if I just click the checkbox on and off.

However, if I click on the image box at any point, the checkbox no longer works (i.e. the image stays in the state it was previously and won't change when I click the checkbox anymore).

I'm sure this is something super-simple I'm missing, but any help would be appreciated. My code is below...


Private Sub CheckBox1_Click()

If CheckBox1.Value = True Then
UserForm1.Image1.Picture = LoadPicture("D:\Storage\Test.jpg")
Else
UserForm1.Image1.Picture = LoadPicture("")
End If

End Sub

John Wilson
07-24-2012, 07:21 AM
Not sure why but try setting the enabled property of Image1 to False

Andy Pope
07-24-2012, 08:57 AM
Try,



Private Sub CheckBox1_Click()

If CheckBox1.Value = True Then
UserForm1.Image1.Picture = LoadPicture("D:\Storage\Test.jpg")
Else
UserForm1.Image1.Picture = LoadPicture("")
End If
UserForm1.Repaint
End Sub

heatdav
07-24-2012, 09:47 AM
Perfect - thanks guys. Andy, I've implemented your change and it works fantastically. (No idea why VBA needs this, but the main thing is it's fixed!). Thanks for your help - much appreciated!