Last active
May 22, 2025 00:49
-
-
Save eugrus/39059aa4a538bd1ce2794c7be8bf84b0 to your computer and use it in GitHub Desktop.
VBA for Word
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Dim myKey | |
' https://learn.microsoft.com/en-us/office/vba/api/word.keybindings.add | |
Private Sub Document_New() | |
KeyBindings_AddKey | |
End Sub | |
Private Sub Document_Open() | |
KeyBindings_AddKey | |
End Sub | |
Sub KeyBindings_AddKey() | |
CustomizationContext = ThisDocument | |
Set myKey = KeyBindings.Add( _ | |
KeyCode:=BuildKeyCode(wdKeyTab), _ | |
KeyCategory:=wdKeyCategoryCommand, _ | |
Command:="TestKeyBindings" _ | |
) | |
End Sub | |
Sub KeyBindings_Clear() | |
CustomizationContext = ThisDocument | |
myKey.Clear | |
End Sub | |
Sub TestKeyBindings() | |
MsgBox "Hello, world!", vbInformation, "KeyBindings Test" | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment