如何在 Outlook 2007 中为 VBA 宏指定键盘快捷方式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/57075/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 09:54:46  来源:igfitidea点击:

How do I assign a keyboard shortcut to a VBA macro in Outlook 2007?

excel-vbaoutlookkeyboard-shortcutsvbaexcel

提问by Magnus Lindhe

How can I assign a keyboard shortcut to a VBA macro in Outlook 2007?

如何在 Outlook 2007 中为 VBA 宏指定键盘快捷方式?

I know how to create a tool for the macro and put it in a menu with an underscore shortcut. This solution requires me to use a shortcut of Alt+ {menu key}+ {tool key}. What if I want to assign it to Alt+ F12or something like that?

我知道如何为宏创建工具并将其放入带有下划线快捷方式的菜单中。该解决方案要求我使用的快捷键Alt+ {menu key}+ {tool key}。如果我想将它分配给Alt+F12或类似的东西怎么办?

The Visual Basic Editor is assigned to the keyboard shortcut Alt+ F11in Outlook 2007. I want to assign a keyboard shortcut like that to a macro, or if necessary a macro on a tool in either a menu or a toolbar.

Visual Basic 编辑器分配给Outlook 2007 中的键盘快捷键Alt+ F11。我想将这样的键盘快捷键分配给宏,或者在必要时分配菜单或工具栏中工具上的宏。

采纳答案by guillermooo

The article Do-It-Yourself IntelliSensefrom MSDN provides excellent information about key bindings in VBA.

这篇文章做它自己的智能感知从MSDN提供了有关VBA键绑定优秀的信息。

回答by rpetrich

Since Outlook doesn't have the OnKey event, the easiest way is to assign a toolbar button to the macro and put an ampersand in its name somewhere. This only works if your shortcut letter doesn't conflict with an existing shortcut.

由于 Outlook 没有 OnKey 事件,因此最简单的方法是为宏分配一个工具栏按钮,并在其名称中的某处放置一个与号。这仅在您的快捷方式字母与现有快捷方式不冲突时才有效。

You may also have luck with setting a global hotkey, but it's usually more pain then it's worth:

您可能也很幸运地设置了全局热键,但这通常比值得的更痛苦:

http://www.mvps.org/vbvision/_samples/HotKey_Demo.zip

http://www.mvps.org/vbvision/_samples/HotKey_Demo.zip