O'Reilly logo

VB & VBA in a Nutshell: The Language by Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SendKeys Statement

Named Arguments

Yes

Syntax

SendKeys string[, wait]

string

Use: Required

Data Type: String

The keystrokes to send.

wait

Use: Optional

Data Type: Boolean

Expression evaluating to True or False denoting the wait mode.

Description

Programmatically simulates specified keys being typed at the keyboard.

Rules at a Glance

  • SendKeys sends its keystrokes to the application and application window that has the focus.

  • One or more characters represent each key.

  • The default setting for wait is False. Setting wait to True informs the application to wait until the keystrokes have been processed before passing control back to the current procedure. A False setting returns control back to the current procedure as soon as the keys are sent.

  • To send normal alphabetical or numeric characters, simply use the character or characters enclosed in quotation marks. For example, "SOME Text 123".

  • The following characters represent special keys or have special meaning within the SendKeys string:

    Character Special Key Representation
    + Shift
    ^ Ctrl
    % Alt
    ~ Enter
    [ ] May be used by Dynamic Data Exchange (DDE)

    To use these characters literally, you must surround the character with braces. For example, to specify the percentage key, use {%}.

  • Preceding a string with the special characters described in the table above allows you to send a keystroke combination beginning with Shift, Ctrl, or Alt. For example, to specify Ctrl followed by M, use ^M.

  • If you need to specify that the Shift, Ctrl, or Alt ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required