E
Eddie V.
Hi, all:
I have a custom template for building technical manuals. I have assigned a
number of custom keystrokes to macros and to a few styles. I generally use
Alt + <something>, since many Alt keystrokes are unassigned. I do, however,
re-assign some built-in keystrokes such as Ctrl + B and Ctrl + I to custom
macros, because I want them to apply Strong and Emphasis characters styles
instead of direct Bold and Italics.
Originally, I assigned the keystokes using Word's GUI, but I later wrote a
procedure to assign them using code. Regardless of the method I use, my
custom keystrokes no longer work. I have looked in the Customize dialog box,
and they're all showing as assigned. I have also re-run the procedure
numerous times, and though it doesn't throw errors, it doesn't seem to be
attaching the keystrokes.
Here's the code:
Sub AssignKeyCombinations()
'Assigns custom keyboard shortcuts to various macros.
CustomizationContext = ActiveDocument.AttachedTemplate
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ToggleBold", _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyB)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ToggleItalics", _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyI)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ToggleBoldAndItalics", _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyE)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ToggleUnderscore", _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyU)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryStyle, _
Command:="List Number", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKey1)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryStyle, _
Command:="List Number 2", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKey2)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryStyle, _
Command:="List Bullet", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyB)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryStyle, _
Command:="List Bullet 2", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyControl, wdKeyB)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="RestartNumbering", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyR)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="RestartSequenceNumbering", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyS)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="UpdateAllFields", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyU)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ShowHideInstructorNotes", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyI)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="UnprotectToolbar", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyT)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="AssignKeyCombinations", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyK)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ShowDocVariableValues", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyV)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ItalicizeCrossReference", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyF)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ShowCustomToolbar", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyJ)
End Sub
Any clues? I appreciate any advice.
I have a custom template for building technical manuals. I have assigned a
number of custom keystrokes to macros and to a few styles. I generally use
Alt + <something>, since many Alt keystrokes are unassigned. I do, however,
re-assign some built-in keystrokes such as Ctrl + B and Ctrl + I to custom
macros, because I want them to apply Strong and Emphasis characters styles
instead of direct Bold and Italics.
Originally, I assigned the keystokes using Word's GUI, but I later wrote a
procedure to assign them using code. Regardless of the method I use, my
custom keystrokes no longer work. I have looked in the Customize dialog box,
and they're all showing as assigned. I have also re-run the procedure
numerous times, and though it doesn't throw errors, it doesn't seem to be
attaching the keystrokes.
Here's the code:
Sub AssignKeyCombinations()
'Assigns custom keyboard shortcuts to various macros.
CustomizationContext = ActiveDocument.AttachedTemplate
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ToggleBold", _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyB)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ToggleItalics", _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyI)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ToggleBoldAndItalics", _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyE)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ToggleUnderscore", _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyU)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryStyle, _
Command:="List Number", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKey1)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryStyle, _
Command:="List Number 2", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKey2)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryStyle, _
Command:="List Bullet", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyB)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryStyle, _
Command:="List Bullet 2", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyControl, wdKeyB)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="RestartNumbering", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyR)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="RestartSequenceNumbering", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyS)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="UpdateAllFields", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyU)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ShowHideInstructorNotes", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyI)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="UnprotectToolbar", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyT)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="AssignKeyCombinations", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyK)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ShowDocVariableValues", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyV)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ItalicizeCrossReference", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyF)
KeyBindings.Add _
KeyCategory:=wdKeyCategoryMacro, _
Command:="ShowCustomToolbar", _
KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyJ)
End Sub
Any clues? I appreciate any advice.