Bogia_hp7 đã viết:
Sói biển có thể nói rõ hơn cách gán tổ hợp phím tắt không? Ví dụ Ctrl + Alt + M chẳng hạn. Cảm ơn bạn!
Syntax
expression.OnKey(Key,
Procedure)
- expression______Required. An expression that returns an Application object.
- Key__________Required String. A string indicating the key to be pressed.
- Procedure____Optional Variant. A string indicating the name of the procedure to be run. If Procedure is "" (empty text), nothing happens when Key is pressed. This form of OnKey changes the normal result of keystrokes in Microsoft Excel. 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.
Remarks
The Key argument can specify any single key combined with ALT, CTRL, or SHIFT, or any combination of these keys. Each key is represented by one or more characters, such as "a" for the character a, or "{ENTER}" for the ENTER key.
To specify characters that aren't displayed when you press the corresponding key (ENTER or TAB, for example), use the codes listed in the following table. Each code in the table represents one key on the keyboard.
Key___________________Code
BACKSPACE___________{BACKSPACE} or {BS}
BREAK________________{BREAK}
CAPS LOCK___________ {CAPSLOCK}
CLEAR________________{CLEAR}
DELETE or DEL_________{DELETE} or {DEL}
DOWN ARROW________{DOWN}
END__________________{END}
ENTER (numeric keypad)__{ENTER}
ENTER________________~ (tilde)
ESC__________________{ESCAPE} or {ESC}
HELP_________________{HELP}
HOME________________{HOME}
INS___________________{INSERT}
LEFT ARROW__________{LEFT}
NUM LOCK___________{NUMLOCK}
PAGE DOWN__________{PGDN}
PAGE UP______________{PGUP}
RETURN______________{RETURN}
RIGHT ARROW_________{RIGHT}
SCROLL LOCK_________{SCROLLLOCK}
TAB___________________{TAB}
UP ARROW_____________{UP}
F1 through F15___________{F1} through {F15}
You can also specify keys combined with SHIFT and/or CTRL and/or ALT. To specify a key combined with another key or keys, use the following table.
To combine keys with ____Precede the key code by
SHIFT_________________+ (plus sign)
CTRL__________________^ (caret)
ALT___________________% (percent sign)
To assign a procedure to one of the special characters (+, ^, %, and so on), enclose the character in braces.
Trên đây là toàn bộ phần help mình trích từ trong VBA, bạn có thể xem thêm
nếu muốn Ctrl + Alt + M thì theo hướng dẫn trên bạn làm như sau:
application.Onkey "^%{M}"
Thân.