Detect Key Entered in Word Form Textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darrylka
    New Member
    • Jun 2007
    • 1

    Detect Key Entered in Word Form Textbox

    I don't know if what I'm needing can be done, but it's worth a forum posting. I'm trying to control whether a macro gets run in a checkbox or not. Right now if I click the checkbox, it runs a macro. That part works great. What I'm trying to do is not run the macro if the checkbox was tabbed to.

    Is there a way to interrogate the last key entered once inside the macro? That way I could just check to see if the last key presses was a tab, and just exit out of the macro.

    Please help if you know how to do this, or if it's even possible.

    Darryl
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    just double click, you should go to the code editor, and in te uper right corner chose the "lost focus" sub

    And write down in that sub the code to run the macro or stop it or whatever you want

    Good Luck

    Comment

    • kadghar
      Recognized Expert Top Contributor
      • Apr 2007
      • 1302

      #3
      mmm

      Now that i read again what you wrote, i think i missunderstood you,

      may be the sub "Change" would be more useful, just write a code to verify that the check box value is true of false. ..

      Hope that helps a little bit more.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by darrylka
        Is there a way to interrogate the last key entered once inside the macro? That way I could just check to see if the last key presses was a tab, and just exit out of the macro.
        I don't think you should need this sort of workaround. Different events should be fired. A checkbox doesn't change every time you tab to it, only when you then hit the space bar.

        So if it's activating when you tab to the control, I'd say you're using the wrong event - GotFocus, perhaps? More likely you'd want to use the Change event, as kadghar suggested.

        Do you want the user to be able to activate it with the keyboard as well, or only the mouse? If the latter, then perhaps MouseDown or MouseUp event would be appropriate.

        Comment

        Working...