Consulting

Results 1 to 4 of 4

Thread: vba to automatically hit a key on the keyboard

  1. #1
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location

    vba to automatically hit a key on the keyboard

    Is there a way to set the return key (enter) on the keyboard to hit automatically at a certain point in your macro?

    I tried

    VBA.KeyCodeConstants.vbKeyReturn = true but it gave me an error of invalid used of property, please help.

  2. #2
    VBAX Tutor nst1107's Avatar
    Joined
    Nov 2008
    Location
    Monticello
    Posts
    245
    Location
    Try SendKeys "~"

  3. #3
    VBAX Tutor
    Joined
    Dec 2008
    Posts
    244
    Location
    can you expand on that a little? thanks

  4. #4
    VBAX Tutor nst1107's Avatar
    Joined
    Nov 2008
    Location
    Monticello
    Posts
    245
    Location
    Copied from Excel Help:


    SendKeys Statement
    Sends one or more keystrokes to the active window as if typed at the keyboard.
    Syntax
    SendKeys string[, wait]
    The SendKeys statement syntax has these named arguments:
    PartDescriptionstringRequired. String expression specifying the keystrokes to send.WaitOptional. Boolean value specifying the wait mode. If False (default), control is returned to the procedure immediately after the keys are sent. If True, keystrokes must be processed before control is returned to the procedure.
    Remarks

    Each key is represented by one or more characters. To specify a single keyboard character, use the character itself. For example, to represent the letter A, use "A"
    for string. To represent more than one character, append each additional character to the one preceding it. To represent the letters A, B, and C, use
    "ABC"
    for string.


    The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses ( ) have special meanings to SendKeys. To specify one of these characters, enclose it within braces ( {}
    ). For example, to specify the plus sign, use
    {+}
    . Brackets ([ ]) have no special meaning to SendKeys, but you must enclose them in braces. In other applications, brackets do have a special meaning that may be significant when dynamic data exchange (DDE) occurs. To specify brace characters, use
    {{}
    and
    {}}
    .

Posting Permissions

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