Consulting

Results 1 to 5 of 5

Thread: Loading a Picture gives Runtime Error 424

  1. #1

    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?

  2. #2
    I guess the syntax is off and should be:

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

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    no thats not it, the image part is actually just in the name. as in the picture box is called UserForm2image

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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'

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    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
  •