Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    860
    Thanks
    0
    Thanked 10 Times in 9 Posts

    ENTER key / VBA (Word XP)

    I have a text control in a user form which I want to be multi-line (MultiLine = TRUE) , so that as the user types many characters, text will wrap within the control. I do NOT want the ENTER key to move focus to the next control in the Tab Order. But I also do not want ENTER to create a new line withint the control; everything must be in a single paragraph.

    I have tried using the KeyPress event to trap ASCII 10 or 13 and then set KeyAscii = 0. This is what I use to suppress certain characters or to substitute one character for another. ENTER doesn't seem to get trapped. Any suggestions on how I can handle this? I suppose I could allow the CRs, and convert them to spaces later on, but I'd prefer to have the user be aware at the time.

    Thanks,
    Richard Barrett

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: ENTER key / VBA (Word XP)

    Use the Key Down event:

    Private Sub TextBox1_KeyDown( _
    ByVal KeyCode As MSForms.ReturnInteger, _
    ByVal Shift As Integer)
    If KeyCode = vbKeyReturn Then
    KeyCode = 0
    End If
    End Sub

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    860
    Thanks
    0
    Thanked 10 Times in 9 Posts

    Re: ENTER key / VBA (Word XP)

    Simple enough! Thank you.
    Richard

Posting Permissions

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