ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   dynamic textbox?? (https://www.excelbanter.com/excel-programming/294403-dynamic-textbox.html)

No Name

dynamic textbox??
 
Can i add textboxes dynamically?? I tried through the
generic code for optionbutton/Checkboxes in a dialog
sheet. it failed as I cannot write anythign on the text
box created.

would appreciate if anyone can suggest.

thanks for the help.

I tried the following 2 ways
1: For i = 1 To 2
iBooks = iBooks + 1
PrintDlg.textBoxes.Add 78, TopPos, 150, 16.5
TopPos = TopPos + 13
Next i
PrintDlg.Buttons.Left = 240

CurrentSheet.Activate
With PrintDlg.DialogFrame
.Height = Application.Max _
(68, PrintDlg.DialogFrame.Top + TopPos - 34)
.Width = 230
.Caption = "Enter worksheet Names to create"
End With
PrintDlg.Buttons("Button 2").BringToFront
PrintDlg.Buttons("Button 3").BringToFront

PrintDlg.Show
If Not cb.Text = "" Then
Str = cb.Text
End If

PrintDlg.Delete
2. Me.Controls.Add (TextBox)..in form

Bob Phillips[_6_]

dynamic textbox??
 
Not sure about the dialogbox, will look into that, but here is some code
showing how to add con trols to a userform

Private Sub CommandButton1_Click()
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

End Sub

Note that you still have a problem of adding code behind the control. AN
alternative approach is to add the control and code at design, but hide it
until you need it.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

wrote in message
...
Can i add textboxes dynamically?? I tried through the
generic code for optionbutton/Checkboxes in a dialog
sheet. it failed as I cannot write anythign on the text
box created.

would appreciate if anyone can suggest.

thanks for the help.

I tried the following 2 ways
1: For i = 1 To 2
iBooks = iBooks + 1
PrintDlg.textBoxes.Add 78, TopPos, 150, 16.5
TopPos = TopPos + 13
Next i
PrintDlg.Buttons.Left = 240

CurrentSheet.Activate
With PrintDlg.DialogFrame
.Height = Application.Max _
(68, PrintDlg.DialogFrame.Top + TopPos - 34)
.Width = 230
.Caption = "Enter worksheet Names to create"
End With
PrintDlg.Buttons("Button 2").BringToFront
PrintDlg.Buttons("Button 3").BringToFront

PrintDlg.Show
If Not cb.Text = "" Then
Str = cb.Text
End If

PrintDlg.Delete
2. Me.Controls.Add (TextBox)..in form





All times are GMT +1. The time now is 02:30 PM.

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