Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jun 2002
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    59
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hi all, once again I am in need of your collective wisdom. I have a user form in Word 2007. There is a test box called Reason_TextBox. When this text box receives focus, the contents are not selected and the insertion point ia at the end of the text. This is, according to VBA help correct :

    "Remarks

    The EnterFieldBehavior property controls the way text is selected when the user tabs to the control, not when the control receives focus as a result of the SetFocus method. Following SetFocus, the contents of the control are not selected and the insertion point appears after the last character in the control's edit region"

    My question is, how do I select all the text (this is a multi-line text box)?

    As usual, your help will be greatly appreciated.

    Raymond

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You could use code like this:

    Code:
    With Me.Reason_TextBox
      .SetFocus
      .SelStart = 0
      .SelLength = Len(.Text)
    End With

  3. #3
    Star Lounger
    Join Date
    Jun 2002
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    59
    Thanks
    2
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='783353' date='07-Jul-2009 16:24']You could use code like this:

    Code:
    With Me.Reason_TextBox
      .SetFocus
      .SelStart = 0
      .SelLength = Len(.Text)
    End With
    [/quote]

    Thanks Hans, as usual you've managed to come to my rescue

    Raymond

Posting Permissions

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