VBA: Programmatically clear a one-key shortcut bound to a document

Joined
Apr 7, 2020
Messages
2
Reaction score
0
Having an awful time turning off a one-key shortcut via VBA.

The first line of code I'm using is:

Code:
CustomizationContext = ActiveDocument

as the shortcut is bound to a document, not to Normal or an add-in.

The helpfiles on keybindings are very spotty, even for Microsoft, but I deduced that one of the lines below should work for the next step:

Code:
KeyBindings(BuildKeyCode(wdKeyF2)).Clear
FindKey(BuildKeyCode(wdKeyF2)).Clear
KeyBindings(wdKeyF2).Clear
FindKey(wdKeyF2).Clear

But they don't. I've even tried KeyBindings.ClearAll (thinking I could programmatically rebuild the others, since there's only 2) but that doesn't work either!

Any ideas? Using the Customize Keyboard dialog isn't an option, for various reasons. This needs to happen in code.

Thanks for any clues.
Mark
 

macropod

Microsoft MVP
Joined
Mar 2, 2012
Messages
578
Reaction score
50
Try:
KeyBindings.Add KeyCode:=wdKeyF2, Command:="", KeyCategory:=wdKeyCategoryDisable
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top