Add Checkbox programatically to form

  • Thread starter Thread starter Matt Jensen
  • Start date Start date
M

Matt Jensen

In my form's initialise event I'm trying to programmatically add a checkbox,
which I wouldn't have thought was too hard, but I just can't get it to work.
Admittedly I'm using trial and error but it's just not happening.
Anyone able to put me out of my misery please?
Thanks
matt
 
Why not add the checkbox in design mode and make it not visible until you
need it. This would be alot simpler.

If you want to pursue your current approach, John Walkenbach has some
information:

http://j-walk.com/ss/excel/tips/tip76.htm

http://j-walk.com/ss/excel/tips/tip44.htm

http://support.microsoft.com/default.aspx?scid=kb;en-us;185774
How to Programmatically Manipulate a UserForm
has a section "Adding Controls to the UserForm"

http://support.microsoft.com/default.aspx?scid=kb;en-us;829070
How to use Visual Basic for Applications (VBA) to change UserForms in Excel
2003, Excel 2002, and Excel 2000
 
Matt,

Here is a simple example


Set newButton = Me.Controls.Add("Forms.Checkbox.1")
newButton.Caption = "Another Checkbox"

With newButton
.Left = 100
.Top = 50
.Visible = True
End With

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Thanks Bob
Matt

Bob Phillips said:
Matt,

Here is a simple example


Set newButton = Me.Controls.Add("Forms.Checkbox.1")
newButton.Caption = "Another Checkbox"

With newButton
.Left = 100
.Top = 50
.Visible = True
End With

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top