How do I assign a shortcut key to a MS Word subroutine?
I already know how to do it via the "Customize Ribbon" Options menu, but I'm interested in hardcoding the keys inside a macro file.
I understand I need to use something like the code below, but where exactly do I insert this code? I tried adding it to the 'ThisDocument' section, without any success.
Code:
With Application
.CustomizationContext = ThisDocument
.KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyF1), _
KeyCategory:=wdKeyCategoryCommand, _
Command:="printAllRecords"
End With
source:
VBA Word: how to call a function via shortcut key?
As an example, what I need is to call "MyScript1" subroutine when pressing Ctrl + L, and "MyScript2" subroutine when pressing Alt + L.
Alex