Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Image on form won't unload (Excel 2002)

    Hi all,

    I thought I would ask this question because I have seen this type of problem before with work that I have done. I have a userform which has 6 image controls to display jpeg files. The file path is read on initalizing of form, from a pathname within a cell on the worksheet. To save on memory, I unload the pictures when the form is unloaded with the a statement image1=nothing. If I load the form again, the image is still there, but if I unload it twice, the picture is gone. I use form1.repaint, but this still has no effect on the form, and will do the same. Is there a way to make this stop? Or a setting that I am not using?

    Thanks Darryl

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Image on form won't unload (Excel 2002)

    I don't understand. When you unload a form, you release the memory it used, so there should be no need to set an image control to nothing.
    When you open the form again, the Form_Initialize event procedure fills the image controls again, so how did you determine that the image hadn't been unloaded?

  3. #3
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Image on form won't unload (Excel 2002)

    Hans you're right, when the form is unloaded it does release the picture, but it still shows the picture. I have tried Repaint but it doesn't work. Do you know how I would test to see if the image control property is a (bitmap), or is (none)?

    Thanks,
    Darryl.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Image on form won't unload (Excel 2002)

    What do you mean by "when the form is unloaded it does release the picture, but it still shows the picture". You don't see the form anymore when it is unloaded, so how can you tell it shows the picture? <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

  5. #5
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Image on form won't unload (Excel 2002)

    When I reload the form the picture remains within the control, even if the pathname of the picture to load is removed . if I unload it, and reload it, the picture is gone. The reason I am asking is I would like to test for the condition if there is a picture loaded or not. If I can't test the control then I will have to test the pathname, which resides within a cell, and is call on initializing the form.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Image on form won't unload (Excel 2002)

    1) Is the picture visible when you view the form in the Visual Basic Editor?
    2) Are you sure you unload the picture instead of just hiding it? If you only hide the picture, it is not unloaded.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •