Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
userform label creation
want to create a userform on the fly. the userform will be created beforehand,
but how would i add a series labels to the existing userform? don't know how many there will be. tried the addlabel method, but can't get it to work. -- Gary |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
userform label creation
Gary, Point of clarification. Do you want to add the labels to the Userform created on the fly? Myles -- Myles ------------------------------------------------------------------------ Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746 View this thread: http://www.excelforum.com/showthread...hreadid=569303 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
userform label creation
myles:
i am just going to use a listbox. seems much easier thanks -- Gary "Myles" wrote in message ... Gary, Point of clarification. Do you want to add the labels to the Userform created on the fly? Myles -- Myles ------------------------------------------------------------------------ Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746 View this thread: http://www.excelforum.com/showthread...hreadid=569303 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
userform label creation
Gary,
Here is some code to show how to add controls Dim newButton As MSForms.Control Select Case True Case chkText.Value Set newButton = Me.Controls.Add("Forms.Textbox.1") newButton.Name = "New Textbox" Case chkButton.Value Set newButton = Me.Controls.Add("Forms.CommandButton.1") newButton.Caption = "newCmd" Case chkListbox.Value Set newButton = Me.Controls.Add("Forms.Listbox.1") newButton.Name = "lstTemp" Case chkCheckbox.Value Set newButton = Me.Controls.Add("Forms.Checkbox.1") newButton.Caption = "Another Checkbox" End Select With newButton .Left = 100 .Top = 50 .Visible = True End With but you still have to have some code behind the form to process the control and this is convoluted. Why not just create them at design time? -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... myles: i am just going to use a listbox. seems much easier thanks -- Gary "Myles" wrote in message ... Gary, Point of clarification. Do you want to add the labels to the Userform created on the fly? Myles -- Myles ------------------------------------------------------------------------ Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746 View this thread: http://www.excelforum.com/showthread...hreadid=569303 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
userform label creation
thanks bob:
what i am trying to do is create a form containing a list of names with a checkbox next to each so a user can select which names to remove from the list. the list is contained on a separate sheet and won't always have the same number of names. i was able to create the from using your examples. now i need to figure which name is selected, but since the form is created on the fly, i'm not sure what the name of each textbox or checkbox is. is there a better way? -- Gary "Bob Phillips" wrote in message ... Gary, Here is some code to show how to add controls Dim newButton As MSForms.Control Select Case True Case chkText.Value Set newButton = Me.Controls.Add("Forms.Textbox.1") newButton.Name = "New Textbox" Case chkButton.Value Set newButton = Me.Controls.Add("Forms.CommandButton.1") newButton.Caption = "newCmd" Case chkListbox.Value Set newButton = Me.Controls.Add("Forms.Listbox.1") newButton.Name = "lstTemp" Case chkCheckbox.Value Set newButton = Me.Controls.Add("Forms.Checkbox.1") newButton.Caption = "Another Checkbox" End Select With newButton .Left = 100 .Top = 50 .Visible = True End With but you still have to have some code behind the form to process the control and this is convoluted. Why not just create them at design time? -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... myles: i am just going to use a listbox. seems much easier thanks -- Gary "Myles" wrote in message ... Gary, Point of clarification. Do you want to add the labels to the Userform created on the fly? Myles -- Myles ------------------------------------------------------------------------ Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746 View this thread: http://www.excelforum.com/showthread...hreadid=569303 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
userform label creation
figured out how to name and reference each textbox and checkbox, now i just have
to parse the list of check boxes to see which names to delete. had to use userform!textbox1 and so on -- Gary "Bob Phillips" wrote in message ... Gary, Here is some code to show how to add controls Dim newButton As MSForms.Control Select Case True Case chkText.Value Set newButton = Me.Controls.Add("Forms.Textbox.1") newButton.Name = "New Textbox" Case chkButton.Value Set newButton = Me.Controls.Add("Forms.CommandButton.1") newButton.Caption = "newCmd" Case chkListbox.Value Set newButton = Me.Controls.Add("Forms.Listbox.1") newButton.Name = "lstTemp" Case chkCheckbox.Value Set newButton = Me.Controls.Add("Forms.Checkbox.1") newButton.Caption = "Another Checkbox" End Select With newButton .Left = 100 .Top = 50 .Visible = True End With but you still have to have some code behind the form to process the control and this is convoluted. Why not just create them at design time? -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... myles: i am just going to use a listbox. seems much easier thanks -- Gary "Myles" wrote in message ... Gary, Point of clarification. Do you want to add the labels to the Userform created on the fly? Myles -- Myles ------------------------------------------------------------------------ Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746 View this thread: http://www.excelforum.com/showthread...hreadid=569303 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
userform label creation
Gary,
you could create a control array, and after creating the checkboxes, check it through the app event Dim mcolEvents As Collection Private Sub UserForm_Initialize() Dim cBtnEvents As clsUserFormEvents Dim ctl As msforms.Control 'create your controls here Set mcolEvents = New Collection For Each ctl In Me.Controls If TypeName(ctl) = "CheckBox" Then Set cChkEvents = New clsUserFormEvents Set cChkEvents.mCBGroup = ctl mcolEvents.Add cBtnEvents End If Next End Sub Add a Class (call it clsUserFormEvents) module Option Explicit Public WithEvents mCBGroup As msforms.CheckBox Private Sub mCBGroup _Click() MsgBox mCBGroup.Caption & " has been pressed" End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... figured out how to name and reference each textbox and checkbox, now i just have to parse the list of check boxes to see which names to delete. had to use userform!textbox1 and so on -- Gary "Bob Phillips" wrote in message ... Gary, Here is some code to show how to add controls Dim newButton As MSForms.Control Select Case True Case chkText.Value Set newButton = Me.Controls.Add("Forms.Textbox.1") newButton.Name = "New Textbox" Case chkButton.Value Set newButton = Me.Controls.Add("Forms.CommandButton.1") newButton.Caption = "newCmd" Case chkListbox.Value Set newButton = Me.Controls.Add("Forms.Listbox.1") newButton.Name = "lstTemp" Case chkCheckbox.Value Set newButton = Me.Controls.Add("Forms.Checkbox.1") newButton.Caption = "Another Checkbox" End Select With newButton .Left = 100 .Top = 50 .Visible = True End With but you still have to have some code behind the form to process the control and this is convoluted. Why not just create them at design time? -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... myles: i am just going to use a listbox. seems much easier thanks -- Gary "Myles" wrote in message ... Gary, Point of clarification. Do you want to add the labels to the Userform created on the fly? Myles -- Myles ------------------------------------------------------------------------ Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746 View this thread: http://www.excelforum.com/showthread...hreadid=569303 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Userform Label | Excel Discussion (Misc queries) | |||
Flashing UserForm Label | Excel Programming | |||
Userform blinking label | Excel Programming | |||
UserForm label doesn't load? | Excel Programming | |||
Conditional Checkbox Creation on a UserForm | Excel Programming |