View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default UserForm Initialize event doesn't fire reliably

If you refer to userform1 and it is not loaded, that reference loads it and
fires the initialize event. So I would expect it works exactly as
advertised, but we, the user, are sometimes caught unawares.

If Userform1.Visible = True Then


if userform1 was not currently loaded during execution of this piece of
code, it would be loaded at that time.


--
Regards,
Tom Ogilvy



"RB Smissaert" wrote in message
...
Finally discovered that the Initialize event of VBA userforms doesn't

always
fire at the time when you expect it to fire.
I had some strange bugs that I couldn't figure out as I just presumed that
if you did Load Userform1 the initialize event
would fire and also that it would fire at no other occasion.
I found that for example it could fire when you do:

If Userform1.Visible = True Then

I have no completely bypassed the Initialize event and just made a normal
Sub that does the same and run this
just before doing Load Userform1.
Seems that this is much better.
I am dealing with a large complicated .xla add-in here and maybe the above
doesn't apply to simpler projects.


RBS