Link to home
Start Free TrialLog in
Avatar of Saqib Husain
Saqib HusainFlag for Pakistan

asked on

Dim'ing textbox

How do I dim a textbox in VBA for excel?
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

You don't. You just use the name of the textbox and do things like Msgbox MyTextbox.Text.
Avatar of Arana (G.P.)
Arana (G.P.)

you can  try locked, visible or enabled properties.    textbox.locked=true
Avatar of Saqib Husain

ASKER

I mean if I want to


Set tb = ws.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 0, 1, 1)

ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Actually if you are talking about dynamically creating a new textbox in a userform, you can do this.

Private Sub CommandButton1_Click()
Dim tb As New TextBox

With tb
    .Visible = True
    .Width = 50
    .Left = 20
    .Text = "New textbox"
End With

End Sub

Open in new window

you have to create a userform
and then :
Dim tBox_n As Control
Set tBox_n = usrFrm.Controls.Add("Forms.TextBox.1", "tBox_n", True)
With tBox_n
    .Top = 10
    .Left = 20
    .Height = 89
    .MultiLine = True
    .EnterKeyBehavior = True
End With

Open in new window