How to get a menu button that is assigned to a macro to display the keyboard shortcut on the menu

Article contributed by Dave Rado

Menu buttons linked to built-in commands (usually) automatically display the shortcut key that is linked to that command (if there is one).

So for instance, on the File menu you can see that Save is assigned to Ctrl+S.

Unfortunately, in Word 97 and above, menu buttons linked to macros do not display the shortcut key that the macro is linked to (they did, automatically, in Word 95 and below.

Fortunately, there is a virtually undocumented workaround for this. It involves running a one-line macro, but the macro only needs to be run once (you could run it from the Immediate Window – press Ctrl+G, or select View + Immediate Window): 

CommandBars("MyCommandBarName").Controls("NameOfMyNewButton"). _
        ShortcutText = "Alt+Ctrl+X"

Or if your button is on a menu you'd use something like:

CommandBars("MenuBarName").Controls("NameOfMenu"). _
        .Controls("NameOfMyNewButton").ShortcutText  = "Alt+Ctrl+X"

Then hold the Shift key down and select File + Save All.

Incidentally, I called it virtually undocumented because, whilst the ShortcutText  property is mentioned in Help, it is not listed as a property of the CommandBarControl object, and nor does it appear under AutoListMembers if you type:

CommandBars("Whatever").Controls(1).

You can only use the ShortcutText property if the button is assigned  to a macro, unfortunately. If it is assigned to a Word command, and if you want to change the shortcut text that appears when you hover over the button, you need to create a custom button assigned to a macro, and replace the built-in button with your custom one. The macro you assign the button to should invoke the command.

Two examples of why one might want to do this are the File + Close and File + Print Preview buttons, which for some weird reason don't display their shortcut keys (Ctrl+F4 and Ctrl+F2, respectively).