ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForm Loads Slowly (https://www.excelbanter.com/excel-programming/372328-userform-loads-slowly.html)

Stratuser

UserForm Loads Slowly
 
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?

Die_Another_Day

UserForm Loads Slowly
 
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 wrote:
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?



Stratuser

UserForm Loads Slowly
 


"Stratuser" wrote:

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?


Stratuser

UserForm Loads Slowly
 
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.

"Stratuser" wrote:

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?


Die_Another_Day

UserForm Loads Slowly
 
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

Stratuser wrote:
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.

"Stratuser" wrote:

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?



Stratuser

UserForm Loads Slowly
 
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.

"Die_Another_Day" wrote:

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

Stratuser wrote:
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.

"Stratuser" wrote:

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?




Dave Peterson

UserForm Loads Slowly
 
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)????

Stratuser wrote:

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?


--

Dave Peterson

Stratuser

UserForm Loads Slowly
 
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.

"Dave Peterson" wrote:

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)????

Stratuser wrote:

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?


--

Dave Peterson


Tom Ogilvy

UserForm Loads Slowly
 
Putting in Doevents does not make the form unload if you used the Hide
command.

--
Regards,
Tom Ogilvy

"Stratuser" wrote in message
...
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.

"Dave Peterson" wrote:

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)????

Stratuser wrote:

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?


--

Dave Peterson





All times are GMT +1. The time now is 02:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com