April 2006
Beginner
1114 pages
98h 16m
English
Application.OnKey(Key, [Procedure])
Assigns a macro to run when a key is pressed. Can also be used to disable built-in Excel key combinations.
|
Argument |
Setting |
|---|---|
|
|
The key combination to assign. The character codes are the same as for |
|
Procedure |
The name of the macro to run. Setting to |
The following code demonstrates how to reassign, disable, and restore a built-in key assignment:
Sub TestOnKey( )
' Reassign Ctrl+C
Application.OnKey "^c", "CopyMsg"
' Disable Ctrl+C
'Application.OnKey "^c", ""
' Restore Ctrl+C
' Application.OnKey "^c"
End Sub
Sub CopyMsg( )
MsgBox "You can't copy right now."
End SubRead now
Unlock full access