Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Initializing a form... (Word 97)

    I have a user form with initialized values:
    txtNumRows.Text = 2
    txtNumCol.Text = 2

    When the user click the macro button and receives the user form, the values are appropriately populated, but I would like them to be highlighted/Selected, so that they don't have to backspace to alter the value. I can't seem to find the property that will do that.... Help Please.....

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Initializing a form... (Word 97)

    Well,

    Since they are two separate text boxes, you can't select both. You can only select one.

    txtNumRows.SelStart = 0
    txtNumRows.SelLen = len(txtNumRows.Text)

    However, it you put that code in the GotFocus event of the Text box, the value will be selected whenever the text box receives the focus.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Initializing a form... (Word 97)

    Worked like a charm! Thanks!

    Private Sub UserForm_Initialize()
    'Set row value to 2
    txtNumRows.Text = 2
    txtNumRows.SelStart = 0
    txtNumRows.SelLength = Len(txtNumRows.Text)

    'Set Column value to 2
    txtNumCol.Text = 2
    txtNumCol.SelStart = 0
    txtNumCol.SelLength = Len(txtNumCol.Text)
    End Sub

  4. #4
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Initializing a form... (Word 97)

    Ooops....
    When the user form comes up, the value was 2 (highlighted). I press 6 and the number 66 appears?
    When I tab and alter the second value, no problem..... what's up?

  5. #5
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Initializing a form... (Word 97)

    I found it,
    In my playing/testing, I had dropped the line of code that was carrying over:

    Private Sub txtNumRows_Change()
    txtNumRows.SelText = txtNumRows.Text
    txtNumRows.SelLength = Len(txtNumRows.Text)
    End Sub

Posting Permissions

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