Dan
Dan

Reputation: 7724

Listing macros in word

I am attempting the list all the commands and what key they a assigned to in Microsoft Word. However I am getting the problem of it only listing the macros/commands which I have made, and not the ones which come the software; such as File Save or PrintPreviewAndPrint.

The macro I am currently using is;

Sub ListKeyboardAssignments()
  Dim kb As KeyBinding
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryNil Then
      Selection.TypeText (kb.Command + " " + kb.KeyString + " //Nil")
      Selection.TypeParagraph
    End If
  Next kb
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryDisable Then
      Selection.TypeText (kb.Command + " " + kb.KeyString + " //Disable")
      Selection.TypeParagraph
    End If
  Next kb
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryCommand Then
      Selection.TypeText (kb.Command + " " + kb.KeyString + " //Command")
      Selection.TypeParagraph
    End If
  Next kb
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryMacro Then
      Selection.TypeText (kb.Command + " " + kb.KeyString + " //Macro")
      Selection.TypeParagraph
    End If
  Next kb
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryMacro Then
      Selection.TypeText (kb.Command + " " + kb.KeyString + " //Prefix")
      Selection.TypeParagraph
    End If
  Next kb
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryFont Then
      Selection.TypeText (kb.Command + " " + kb.KeyString + " //Font")
      Selection.TypeParagraph
    End If
  Next kb
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryAutoText Then
      Selection.TypeText (kb.Command + " " + kb.KeyString + " //AutoText")
      Selection.TypeParagraph
    End If
  Next kb
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryStyle Then
      Selection.TypeText (kb.Command + " " + kb.KeyString + " //Style")
      Selection.TypeParagraph
    End If
  Next kb
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategorySymbol Then
      Selection.TypeText (kb.Command + " " + kb.KeyString + " //Symbol")
      Selection.TypeParagraph
    End If
  Next kb
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryPrefix Then
      Selection.TypeText (kb.Command + " " + kb.KeyString + " //Prefix")
      Selection.TypeParagraph
    End If
  Next kb
End Sub

Edit

This macro also does not list all the macros the macros/commands which I have made. Any help in fixing this would be greatly appreciated

Upvotes: 0

Views: 380

Answers (1)

Jean-Pierre Oosthuizen
Jean-Pierre Oosthuizen

Reputation: 2693

KeyBindings only refer to your Customize Shortcuts.

If you just want a Table of all the Standard Word Based Shortcuts then you want to use:

 Application.ListCommands ListAllCommands:=True

This will open a new document and then insert a Table with the command name and the keystring.

Upvotes: 1

Related Questions