PDA

View Full Version : Loading a Picture gives Runtime Error 424



AlexMason
03-19-2010, 03:50 AM
Hey guys a friend of mine is trying to do something excel using userForms.

the premise is this:

UserForm1 comes up and its got sliders, some buttons and a picture box. you use the sliders to set some numbers, press plot, a graph is generated and a gif image of that is loaded to the picture box. this image is stored in a pre-determined location on D:\

if you press save plot, UserForm2 then pops up. ideally UserForm2 will pop up and load the same image into another picture box.

however, UserForm2 is popping up then doing nothing. it gives the error

Runtime Error 424 : Object Required when trying to load the picture.

heres the code when you press the save plot command button

Private Sub CommandButton3_Click()
Load UserForm2

UserForm1.Hide
UserForm2.Show

UserForm2image.Picture = LoadPicture("D:\Data\energy gen\transfer\Mychart.gif")

End Sub
it gets stuck on that last line, a line that works perfectly fine for UserForm1. is it a case of unloading from one and loading to the other?

Jan Karel Pieterse
03-19-2010, 08:43 AM
I guess the syntax is off and should be:

UserForm2.image.Picture = LoadPicture("D:\Data\energy gen\transfer\Mychart.gif")

AlexMason
03-19-2010, 08:55 AM
no thats not it, the image part is actually just in the name. as in the picture box is called UserForm2image

mdmackillop
03-19-2010, 10:22 AM
Try adding DoEvents after the image is stored.

Paul_Hossler
03-19-2010, 04:26 PM
Try adding

UserForm2.Repaint after you load the picture

Paul