VBA (Excel 2007) - 怎样才能|使用 Onkey 覆盖默认快捷方式行为

发布于 2024-10-01 10:29:24 字数 350 浏览 8 评论 0原文

Excel 2007 与 Excel 2003 不同,它使用 Alt+CAlt+S 等热键Alt+V 就像特定功能的快捷方式。

所以如果我在 VBA 模块中使用

         Application.OnKey("%C","ProcAltC")  

它就不起作用。换句话说,按 Alt+C 不会调用“ProcAltC”例程。

如何覆盖默认快捷方式行为才能成功使用 OnKey

Excel 2007, different from Excel 2003, uses hotkeys like Alt+C, Alt+S, Alt+V like shortcuts to specific features.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瞄了个咪的 2024-10-08 10:29:24

在 Office 2010 中,我可以通过... Alt+CAlt+S 生成

    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 是一个不同的故事。如果您绝对必须使用像 Alt+V 这样的组合,则必须编译并使用操作系统系统挂钩。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文