UserForm Loads Slowly

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a userform that has two list boxes, each of which are filled with
about 100 filenames. Even when I have run this form before and already have
it loaded with data and the form is just hidden, it takes several (7-10)
seconds to reappear when I invoke it again. I'm trying to figure out a way
to speed up the reappearance of the form when I call it again. If I'm not
adding any data to the listboxes or re-running the filesearch command that I
used to fill the listboxes, why should it take this long for it to reappear
when called? Any ideas for speeding it up?
 
What code do you have in the Userform Initialize and Userform Activate
events? Also do you have objects stored in frames on the userform? I've
had issues with frames causing extremely slow performance if not called
correctly.

Charles
 
Stratuser said:
I have a userform that has two list boxes, each of which are filled with
about 100 filenames. Even when I have run this form before and already have
it loaded with data and the form is just hidden, it takes several (7-10)
seconds to reappear when I invoke it again. I'm trying to figure out a way
to speed up the reappearance of the form when I call it again. If I'm not
adding any data to the listboxes or re-running the filesearch command that I
used to fill the listboxes, why should it take this long for it to reappear
when called? Any ideas for speeding it up?
 
There are no frames on the userform. And when the form is activated, the
code just resets some of the checkboxes. The filesearch procedure that fills
the two listboxes happens during the initialization only. That's why I
can't figure out what's taking so long when all I'm doing is reactivating the
userform.
 
Put a break point on the command to re-activate the userform, then
single step through until you find the command that zaps all the time.

Charles Chickering
 
Okay, when I "show" the userform, the initialization sub is running, and that
what's taking the time. Now I need to figure out why it's initializing,
instead of just activating.
 
Just some guesses...

Excel uses the windows temporary folder for lots of stuff--including files that
are required for these controls.

When that folder gets loaded with lots of stuff, excel can get confused.

I'd close excel and clean up that folder.

Close excel
windows start button|Run
%temp%
is a quick way to get to that temporary folder.

Clean up everything you can.

=========
If this problem only occurs on one particular pc (or for one user on that pc),
it might even solve the problem!

But if it happens for lots of people on lots of pcs, it may not be the solution.

Depending on what you're doing, maybe just hiding and reshowing would be a
better that unloading and reloading (if that's what you are doing)????
 
I think I have found the problem. In the command button that executes some
code on the form, I used the "DoEvents" command after "Me.Hide" (I think I
put that in there a while back to get the form off the screen). But it may
have caused the form to unload, which is not what I intended, and so the form
was going through the lengthy initialization sub every time (and then it has
to look up all those files and repopulate the listboxes). Taking out
"DoEvents" seems to fix the problem by avoiding the initialization sub.

Basically, I only want the initialization sub to run the first time the form
appears and when I have changed the list of files in a certain subdirectory.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top