How can I assign a keyboard shortcut to a VBA macro in Outlook 2007?
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 + F12 or something like that?
The Visual Basic Editor is assigned to the keyboard shortcut Alt + F11 in 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.
Run a macro with custom keyboard shortcutOn the Developer tab, in the Code group, click Macros. In the Macro dialog box, click Options. The Macro Options dialog box will appear. In the Shortcut key box, type any uppercase or lowercase letter that you want to use for the shortcut, and then click OK to save the changes.
You could run your macro by using a shortcut key. Shortcut keys are case sensitive. Select (Tools > Macro > Macros) to display the Macro dialog box. Select the macro that you want to assign a shortcut key to and press the "Options" button.
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.
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
The article Do-It-Yourself IntelliSense from MSDN provides excellent information about key bindings in VBA.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With