PDA

View Full Version : Editing Initialize Procedures for Dynamic User Forms



bbk5
07-02-2007, 12:54 PM
I'm writing some procedures that will create user forms on the fly. The problem I'm running into is adding code to the forms themselves (ie. UserForm_Initialize). As it stands now, I don't have a way of populating comboBoxes since I can't figure out a way to create an initialization procedure dynamically.

Does anyone have any advice on how to achieve this dynamically? Thanks!

Bob Phillips
07-02-2007, 01:03 PM
When you create a form on the fly, you have to becareful where you load the combobox. The form isn't actually loaded into memory until it reaches the Show statement. At this point the combobox is cleared so you need to re load the List property.



Dim frmTest

Set frmTest = VBA.UserForms.Add(frmForm.Name)

frmTest.Controls("cboWordList").List = ListArray

frmTest.Show

mikerickson
07-02-2007, 03:00 PM
The techniques for writting to a newly created userform are discussed here. http://www.ozgrid.com/forum/showthread.php?t=69411

I discovered that creating and removing userforms on the fly bloats the file size. Every time you remove a userform, not all of the memory is freed up. Your file size grows with each instance of the temporary userform.

lucas
07-02-2007, 05:28 PM
I discovered that creating and removing userforms on the fly bloats the file size. Every time you remove a userform, not all of the memory is freed up. Your file size grows with each instance of the temporary userform.

Not to mention that it overcomplicates things unnessarily....