Tuesday, October 6, 2020

Assigning shortcut keys to existing macros in MS Word

This post is written based on MS Word 15 (running on Windows 8). Suppose I already have three macros defined as follows:

Sub Code()
    Selection.Font.Name = "Courier New"
    Selection.Font.Size = 9
End Sub

Sub CodeBackground()
    Selection.Shading.Texture = wdTextureNone
    Selection.Shading.ForegroundPatternColor = wdColorAutomatic
    Selection.Shading.BackgroundPatternColor = RGB(220,220,220)
End Sub

Sub Body()
    Selection.Font.Name = "Times New Roman"
    Selection.Font.Size = 11
End Sub
And I want to reassign a new shortcut key to each macro function above.

1. Right click on the menu bar and select Customize the Ribbon...


2. From the Customize Ribbon dialog box, click on Customize... button


3. When the Customize Keyboard opens:
> choose Macros from the Categories list box 
> select the macro name (for example, Code) in the Macros list box on the right
> click on "Press new shortcut key" textbox and press any shortcut key, for example, Ctrl + 0.
> click on the Assign button (it assigns Ctrl + 0 shortcut key to the selected macro named Code).




No comments:

Post a Comment