-
Loading a Picture gives Runtime Error 424
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
[vba]Private Sub CommandButton3_Click()
Load UserForm2
UserForm1.Hide
UserForm2.Show
UserForm2image.Picture = LoadPicture("D:\Data\energy gen\transfer\Mychart.gif")
End Sub[/vba]
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?
-
I guess the syntax is off and should be:
UserForm2.image.Picture = LoadPicture("D:\Data\energy gen\transfer\Mychart.gif")
-
no thats not it, the image part is actually just in the name. as in the picture box is called UserForm2image
-
Try adding DoEvents after the image is stored.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
Try adding
UserForm2.Repaint after you load the picture
Paul
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules