开发者

VBA (Excel 2007) - How can | override default shortcut behaviour with Onkey

开发者 https://www.devze.com 2023-01-23 14:54 出处:网络
Excel 2007, different from Excel 2003, uses hotkeys like Alt+C, Alt+S, Alt+V like shortcuts to specific feature开发者_JS百科s.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号