ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MSForm 2 - Creating labels and text boxes at run time (https://www.excelbanter.com/excel-programming/312159-msform-2-creating-labels-text-boxes-run-time.html)

Tim Coddington

MSForm 2 - Creating labels and text boxes at run time
 
Is CreateObject used to place a new label or text box onto a form at run
time? All I could find in the examples is how to create applications or
workbooks:
Set xlApp = CreateObject("Excel.Application")

Thanks in advance,
-Tim



Bob Phillips[_6_]

MSForm 2 - Creating labels and text boxes at run time
 
No, here is an example

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 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


--

HTH

RP

"Tim Coddington" wrote in message
...
Is CreateObject used to place a new label or text box onto a form at run
time? All I could find in the examples is how to create applications or
workbooks:
Set xlApp = CreateObject("Excel.Application")

Thanks in advance,
-Tim





Tim Coddington

MSForm 2 - Creating labels and text boxes at run time - My thanks
 
AAAAAH. Thanks, Bob!
"Bob Phillips" wrote in message
...
No, here is an example

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 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


--

HTH

RP

"Tim Coddington" wrote in message
...
Is CreateObject used to place a new label or text box onto a form at run
time? All I could find in the examples is how to create applications or
workbooks:
Set xlApp = CreateObject("Excel.Application")

Thanks in advance,
-Tim








All times are GMT +1. The time now is 04:16 PM.

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