Results 1 to 2 of 2

Thread: TextBox con error Object doesn´t support this property or method
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Dec 2017
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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

  2. #2
    Board Regular MrIfOnly's Avatar
    Join Date
    Nov 2016
    Location
    Wisconsin
    Posts
    489
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

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

    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
    *************************************************
    Rate Schedule:

    • Answers: $1
    • Correct Answers: $2
    • Dumb looks are still free.

    *************************************************

    Want to make your listbox column widths adjustable? Take a look at this YouTube video and this sample file on RoryA's informative website: Tips and tricks | Excel Matters

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •