TextBox con error Object doesn´t support this property or method

ale348

New Member
Joined
Dec 19, 2017
Messages
1
Hola buen día,

No se mucho de excel vba, lo que he hecho es en base a tutoriales. Necesito ayuda por favor con un código que llevo días tratando de resolver y no puedo. Tengo mas código hecho pero esta es la parte donde tengo problemas, en el renglon en Negritas y subrayado es donde me aparece el error Object doesn´t support this property or method. No se que hacer, les agradezco su apoyo.

Saludos!



Call NUMLINEAS

Dim Label1 As Object
Dim txtB1 As Control


For NL = 1 To NumeroLineas

Set Label1 = UserForm2.Controls.Add("Forms.Label.1", "MYLABELS", True)
With Label1
.Caption = "Nombre Linea " & NL
.Height = 24
.Width = 132
.Left = 10
' .Font.Bold = True
' .Font.Size = 16
.Top = 18 * NL * 2
End With

Set txtB1 = UserForm2.Controls.Add("Forms.TextBox.1", "TxtBx" & NL, True) 'nombres de textboxes: TxtBx1, TxtBx2, TxtBx3, etc
With txtB1
.Name = "TxtBx" & NL
.Height = 25.5
.Width = 150
.Left = 150
.Top = 18 * NL * 2
' Cells(10, 11) = txtB1.Name
End With



Next NL
Cells(10, 11).Value = txtB1.Value
UserForm2.Show


EN LA USERFORM2 TENGO ESTO:

Private Sub CommandButton1_Click()


If ActiveSheet.TxtBx1.Text = "" Then
MsgBox ("Cannot empty!")
Else
ActiveSheet.Range("J10").Value = TxtBx1.Text
End If
If TxtBx2.Text = "" Then
MsgBox ("Cannot empty!")
Else
Range("J11").Value = TxtBx2.Text
End If
If TxtBx3.Text = "" Then
MsgBox ("Cannot empty!")
Else
Range("J12").Value = TxtBx3.Text
End If
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hola:

Lo siento, mi español no es bueno. I can understand most of what you write but cannot reply in anything but laughable Spanish. So I hope you can understand this message.

Try replacing your code in Userform2 with the following to fix your problem:

Code:
Private Sub CommandButton1_Click()    If Me.Controls("TxtBx1").Text = "" Then
    MsgBox ("Cannot empty!")
    Else
    ActiveSheet.Range("J10").Value = Me.Controls("TxtBx1").Text
    End If
    If Me.Controls("TxtBx2").Text = "" Then
    MsgBox ("Cannot empty!")
    Else
    Range("J11").Value = Me.Controls("TxtBx2").Text
    End If
    If Me.Controls("TxtBx3").Text = "" Then
    MsgBox ("Cannot empty!")
    Else
    Range("J12").Value = Me.Controls("TxtBx3").Text
    End If
End Sub

Saludos,

CJ
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top