Re: there must be a better way - ensuring userforms are closed

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Don Guillett (donaldb_at_281.com)
Date: 09/06/04


Date: Mon, 6 Sep 2004 08:32:50 -0500

try this. You may need to dim each??

For Each f In UserForms
   Unload f
Next

-- 
Don Guillett
SalesAid Software
donaldb@281.com
"JulieD" <JulieD@hctsReMoVeThIs.net.au> wrote in message
news:%23PuaWQBlEHA.3372@TK2MSFTNGP09.phx.gbl...
> Hi All
>
> i have code that should unload a userform when it has finished running the
> code associated with it, but i've found that it doesn't always do it .. so
i
> would like on the initialization of the "menu" userform to ensure that all
> other userforms are closed e.g.
>
> on error resume next
>     unload userform1
>     unload userform2
>
> etc
>
> however, i've noticed that when stepping through this code the form
> initialization code runs for each of the userforms whether or not they are
> displayed - which slows down the code somewhat.
>
> i know that i can check to see if a userform is visible, and if it is to
> close it
> e.g.
>
>     if userform1.visible = true then
>         unload userform1
>     end if
>     if userform2.visible = true then
>         unload userform2
>     end if
>
> but i'm wondering if there is a more efficient way of doing this. (Excel
> 2000 btw)
>
> Cheers
> JulieD
>
>

Quantcast