ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add Checkbox programatically to form (https://www.excelbanter.com/excel-programming/318626-add-checkbox-programatically-form.html)

Matt Jensen

Add Checkbox programatically to form
 
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



Tom Ogilvy

Add Checkbox programatically to form
 
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...b;en-us;185774
How to Programmatically Manipulate a UserForm
has a section "Adding Controls to the UserForm"

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

--
Regards,
Tom Ogilvy


"Matt Jensen" wrote in message
...
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





Matt Jensen

Add Checkbox programatically to form
 
Great - thanks Tom - heaps of useful info there
Cheers
Matt

"Tom Ogilvy" wrote in message
...
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...b;en-us;185774
How to Programmatically Manipulate a UserForm
has a section "Adding Controls to the UserForm"

http://support.microsoft.com/default...b;en-us;829070
How to use Visual Basic for Applications (VBA) to change UserForms in

Excel
2003, Excel 2002, and Excel 2000

--
Regards,
Tom Ogilvy


"Matt Jensen" wrote in message
...
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







Bob Phillips[_6_]

Add Checkbox programatically to form
 
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)


"Matt Jensen" wrote in message
...
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





Matt Jensen

Add Checkbox programatically to form
 
Thanks Bob
Matt

"Bob Phillips" wrote in message
...
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)


"Matt Jensen" wrote in message
...
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








All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com