Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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
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 Label Steve[_9_] Excel Discussion (Misc queries) 7 October 29th 07 09:51 PM
Flashing UserForm Label grahammal[_25_] Excel Programming 1 March 27th 06 03:20 PM
Userform blinking label Ed Excel Programming 2 July 17th 04 12:24 AM
UserForm label doesn't load? Ed[_18_] Excel Programming 4 June 21st 04 07:53 PM
Conditional Checkbox Creation on a UserForm Todd Huttenstine[_2_] Excel Programming 1 November 21st 03 03:38 PM


All times are GMT +1. The time now is 04:12 AM.

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

About Us

"It's about Microsoft Excel"