VBA (Excel 2007) - How can | override default shortcut behaviour with Onkey
Excel 2007, different from Excel 2003, uses hotkeys like Alt+C, Alt+S, Alt+V like shortcuts to specific feature开发者_JS百科s.
So if I use in a VBA module
Application.OnKey("%C","ProcAltC")
It doesn't work. In other words, pressing Alt+C doesn't call "ProcAltC" routine.
How can I override that default shortcut behavior in order to use OnKey
successfully?
In Office 2010 I can produce an action on Alt+C and Alt+S by...
Sub Test01()
With Application
'[lower case c, s, v]:
.OnKey "%c", "Proc01"
.OnKey "%s", "Proc02"
.OnKey "%v", "Proc03"
End With
End Sub
Sub Proc01()
MsgBox "C"
End Sub
Sub Proc02()
MsgBox "S"
End Sub
Sub Proc03()
MsgBox "V"
End Sub
Alt+V is a different story. If you absolutely must use combinations like Alt+V, you're going to have to compile and employ an OS system hook.
精彩评论