Consulting

Results 1 to 3 of 3

Thread: TextBox Help

  1. #1
    VBAX Newbie
    Joined
    Mar 2017
    Posts
    2
    Location

    TextBox Help

    Hello. I hope this doesn't turn out to be a stupid question.

    I've created some simple string manipulation code in VB. I developed it on Excel in Windows 7. When I go to run the code on Mac Excel 2016 (15.32) - the button won't click. When I open up the VB editor in Mac and click Run I get the classic "Run-time error '424': Object required". I click ok, and step through the code - all of the string manipulations work (I'm just adding new lines of text to a variable) but when I go to set the textbox text value I get the error.

    Code is simply

    TextBox1.Text = AppConf

    Again, the code works in windows. If I do a simple "MsgBox AppConf" I get a msg box pop-up that contains the text I'm looking for. When I click on "Selection Pane" I can see my two buttons "CommandButton1" and "CommandButton2" and I see the textbox that I created "TextBox 1". I've tried renaming it to TextBox1 (removed the space). I know it's something silly. Can anyone help?

    Private Sub CommandButton1_Click()

    Dim AppConf As String

    AppConf = "Test text" & vbCrLf
    AppConf = AppConf & "More Text" & vbCrLf

    TextBox1.Text = AppConf



    and then it gives me the error

  2. #2
    VBAX Newbie
    Joined
    Mar 2017
    Posts
    2
    Location
    So I figured it out - I was trying to use a TextBox created in Windows Excel - and that's an ActiveX object. Problem #1 solved
    Problem #2 - I solved the issued, but I'm still confused by this. When I create a "TextBox" in Mac Excel it creates "TextBox 1"..and I could NOT NOT NOT figure out how to reference it or set its value. I found in another thread how to reference the object by it's nice name
    ActiveWorkbook.ActiveSheet.TextBoxes("TextBox 1")
    Using that handle I can manipulate its Text value, etc. I wouldn't have expected the behaviors and treatments to be so different. I'm also sure that there's an easier way to reference the text box. I hope this helps someone else

  3. #3
    When do you generally use Textboxes?

Posting Permissions

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