

That is, you can cancel processing the message sent by KeyPress, either by setting CancelDefault to True, or, if you are using the VisEventProc method to handle the event, by returning True. Unlike some other Visio events, KeyPress does not have the prefix Query, but it is still a query event. If you set CancelDefault to True, Visio does not process the message received when the mouse button is clicked. Can be any ASCII character code.įalse if Microsoft Visio should process the message it receives from this event otherwise, True. The ASCII value of the key that was pressed. KeyPress ( KeyAscii, CancelDefault)Įxpression A variable that represents an Application object. For details, see the example.Occurs when a keyboard key is pressed. To assign a procedure to one of the special characters (+, ^, %, and so on), enclose the character in braces.

* (asterisk) Only applies to Mac may only work on Excel 2011 for Mac and not later versions. To specify a key combined with another key or keys, use the following table. You can also specify keys combined with Shift and/or Ctrl and/or Alt and/or Command. Each code in the table represents one key on the keyboard.

To specify characters that aren't displayed when you press the corresponding key (for example: Enter or Tab), use the codes listed in the following table. Each key is represented by one or more characters, such as a for the character a, or for the Enter key. The Key argument can specify any single key combined with Alt, Ctrl, or Shift, or any combination of these keys. If Procedure is omitted, Key reverts to its normal result in Microsoft Excel, and any special key assignments made with previous OnKey methods are cleared. This form of OnKey changes the normal result of keystrokes in Microsoft Excel. If Procedure is "" (empty text), nothing happens when Key is pressed.

Parameters NameĪ string indicating the key to be pressed.Ī string indicating the name of the procedure to be run. SyntaxĮxpression A variable that represents an Application object. Runs a specified procedure when a particular key or key combination is pressed.
