Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default UserForm_Initialize

I agree Bart.

I tend to have a procedure outside of the userform that loads the form and
does all the initialise biz, then shows it. I find it more manageable.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"RB Smissaert" wrote in message
...
No particular question really, but just an observation and maybe somebody
has some opinion about this.
When you have a complex VBA project with userforms it can be difficult to
control when the UserForm_Initialize
event will be triggered. I have found now that it is just much easier not

to
use this at all and make a procedure
that runs all the code that normally would go into UserForm_Initialize.
Then you can run this procedure whenever you want, for example after Load
UserForm.
Doing this gives you me more control and avoids problems.

RBS



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default UserForm_Initialize

Hi Bob,

Thanks for confirming.
In fact I still had one thing in UserForm_Initialize.
Simplified:

Private WithEvents xlApp As Excel.Application

Private Sub UserForm_Initialize()

Set xlApp = Excel.Application

End Sub

But I have now taken this out as well:

Private lMainFormHwnd As Long
Private WithEvents xlApp As Excel.Application

Public Property Let propFormHwnd(lHwnd As Long)

lMainFormHwnd = lHwnd

Set xlApp = Excel.Application

End Property

Public Property Get propFormHwnd() As Long
propFormHwnd = lMainFormHwnd
End Property

Where the property propFormHwnd gets set in the procedure that replaces
UserForm_Initialize.
I needed the hwnd of this form in any case so I used this the Property Let
procedure.

RBS


"Bob Phillips" wrote in message
...
I agree Bart.

I tend to have a procedure outside of the userform that loads the form and
does all the initialise biz, then shows it. I find it more manageable.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"RB Smissaert" wrote in message
...
No particular question really, but just an observation and maybe somebody
has some opinion about this.
When you have a complex VBA project with userforms it can be difficult to
control when the UserForm_Initialize
event will be triggered. I have found now that it is just much easier not

to
use this at all and make a procedure
that runs all the code that normally would go into UserForm_Initialize.
Then you can run this procedure whenever you want, for example after Load
UserForm.
Doing this gives you me more control and avoids problems.

RBS




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm_Initialize error Jennifer Excel Programming 3 April 24th 05 09:58 PM
UserForm_Initialize() Joe Derr[_2_] Excel Programming 3 December 4th 04 04:23 AM
Userform_Initialize event failing to be called R Avery Excel Programming 2 March 3rd 04 04:06 AM
UserForm_Initialize Rob Excel Programming 2 January 15th 04 02:00 PM
UserForm_Initialize? How to update. Jelso Excel Programming 2 September 5th 03 07:51 AM


All times are GMT +1. The time now is 12:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"