SEND.KEYS macro

Sends keystrokes to the active application just as if they were typed at the keyboard. Use SEND.KEYS to send keystrokes that perform actions and execute commands to applications you are running with Microsoft Excel's other dynamic data exchange (DDE) functions.

Syntax

SEND.KEYS(key_text, wait_logical)

Note   This function is available only in Microsoft Excel for Windows.

Key_text    is the key or key combination you want to send to another application. The format for key_text is described in the ON.KEY function.

Wait_logical    is a logical value that determines whether the macro continues before the actions caused by key_text are carried out.

 

Remarks

If Microsoft Excel is the active application, wait_logical is assumed to be FALSE, even if you enter wait_logical as TRUE. This is because if wait_logical is TRUE, Microsoft Excel waits for the keys to be processed in the other application before returning control to the macro. Microsoft Excel doesn't process keys while a macro is running.

Example

The following macro uses the Calculator application in Microsoft Excel for Windows to multiply some numbers, and then cuts the result and pastes it into Microsoft Excel.

=EXEC("CALC.EXE", 1)

=SEND.KEYS("10*30", TRUE)

=SEND.KEYS("~", TRUE)

=SEND.KEYS("%ec", TRUE)

=APP.ACTIVATE(, FALSE)

=SELECT(!B1)

=PASTE()

=RETURN()

Related Functions

APP.ACTIVATE   Switches to an application

EXECUTE   Carries out a command in another application

ON.KEY   Runs a macro when a specified key is pressed

Return to index