Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    May 2002
    Location
    Fort Worth, Texas, USA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code for # of Keystrokes to Trigger Cursor Move (Word 2000)

    Try this:

    <pre>Private Sub TextBox_Change()
    Static X As Integer
    If X = 1 Then
    NextText.SetFocus
    X = 0
    Else
    X = X + 1
    End If
    End Sub
    </pre>

    Using Static to dim X causes it to remember the value from one call to the next.

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code for # of Keystrokes to Trigger Cursor Move (Word 2000)

    Hi Sherry,
    If you are using a userform this is easily accomplished without code. Just use a textbox control and set 2 properties: MaxLength=2 and AutoTab=true.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Location
    Stone Ridge, New York, USA
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code for # of Keystrokes to Trigger Cursor Move (W

    <P ID="edit" class=small>(Edited by SherryThing on 28-Aug-03 22:30. Can't use a userform for this.)</P>Does anyone know of any code that would cause the cursor to move to the next formfield after a certain number of keystrokes. What I need is for the cursor to move to the next formfield after any, say, two keystrokes are entered into the current formfield - so the User doesn't have to hit the Tab key to get to the next formfield. This is a protected form in Word. I need code to do this in the actual Word form document - not in a Userform.

    THANKS.

  4. #4
    Star Lounger
    Join Date
    Apr 2002
    Location
    Stone Ridge, New York, USA
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code for # of Keystrokes to Trigger Cursor Mov

    Hi Kevin and Loren Ann,

    Thanks for these suggestions. However, I realize now that we need to use the formfields within the actual form document. A userform won't work with the form we're working with. So I'm looking for an on-entry macro I suppose, that will cause the cursor to move forward to the next formfield after x number of keystrokes. I don't know if this is at all possible though...

    Sherry

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code for # of Keystrokes to Trigger Cursor Mov

    I learned early on that formfields are not quite as flexible or as powerful (from a programming perspective) as userform controls. I hope you find an answer. If so, let us know what it is. I'm curious to know how it can be done with ffields.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Code for # of Keystrokes to Trigger Cursor Mov

    Oh, this is bad. There is an application event in Word known as WindowSelectionChange. It monitors many different types of "moves," but it does not trigger for continuous typing. So even with all the rigamarole of testing it, it won't help. This might not be something that Word's standard Form controls can do.

    <center>

    <img src=/w3timages/blueline.gif width=33% height=2></center>

    For future reference, here was the test environment:

    Word document with two text fields, the first one limited to 3 characters.

    In the document,
    1. <LI>A class module named clsWordAppEvents containing the following code:
      <pre>Option Explicit
      Public WithEvents wdApp As Word.Application

      Private Sub wdApp_WindowSelectionChange(ByVal Sel As Selection)
      ' Write selection "end" position, field name, field "results" to Immediate window
      Debug.Print Sel.End, Sel.Bookmarks(1).Name, _
      ActiveDocument.FormFields(Sel.Bookmarks(1).Name).R esult
      End Sub</pre>

      <LI>A regular code module (name not important) containing the following code:
      <pre>Option Explicit
      Dim wdEvts As New clsWordAppEvents

      Sub RegisterAppEvtHandler()
      Set wdEvts.wdApp = Word.Application
      End Sub</pre>
    Resized the windows so I could watch the Immediate window as I typed in the document (protected for forms), ran the RegisterAppEvtHandler sub and then tested.

Posting Permissions

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