Resting Anchor

The Anchorage

Personal website of Gregory K. Maxey, Commander USN (Retired)

List All Keyboard Shortcuts
(A Microsoft Word Help & Tip page by Gregory K. Maxey)

DISCLAIMER/TERMS OF USE

The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.

Click to acces PayPal Verification Service Click to acces PayPal Verification Service

However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.

If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!


The purpose of this Microsoft Word Tips & Microsoft Word Help page is to provide a macro solution to create a composite listing of all keyboard shortcuts.  The composite listing includes all custom keybindings (shortcuts) which you have defined and assigned to execute commands, macros, styles, fonts, building blocks, or common symbols, and the current shortcut combinations defined for Words built-in commands.

A representative list is shown below:

list all shortcuts 1

Background\Discussion

I've been a mouse man for a very long time.  Primarily I use the mouse because, if for no other reason, I can't remember the keyboard shortcuts for all the various Word commands!

I knew that in Word, at least versions 2003 - 2013, I could create a list of current keyboard settings using the Word command "ListCommands" and that I could print (hard copy) a list of custom key assignments.    

This left me with a two separate incomplete lists:

Using the following macro, I can create a composite, complete listing of keyboard shortcuts that I can save as a Word document or print.

VBA Script:
Option Explicit
Sub ListCompositeShortcuts()
Dim oDoc As Word.Document
Dim oDocTemp As Word.Document
Dim oKey As KeyBinding
Dim oTbl_1 As Word.Table, oTbl_2 As Word.Table
Dim oRng As Word.Range
Dim lngIndex As Long
Dim oRow As Word.Row

  'Create a new document for listing composite shortcuts.
  Set oDoc = Documents.Add(, , wdNewBlankDocument)
  Set oRng = oDoc.Range
  System.Cursor = wdCursorWait
  Application.ScreenUpdating = False
  'List and sort custom keybindings.
  For lngIndex = 1 To KeyBindings.Count
    Set oKey = KeyBindings(lngIndex)
    oRng.InsertAfter vbCr & oKey.KeyCategory & vbTab & oKey.Command _
                   & vbTab & oKey.KeyString
    'Update status bar.
    Application.StatusBar = "Processing custom keybinding " & lngIndex & " of " & _
                             KeyBindings.Count & ".  Please wait."
    DoEvents
  Next lngIndex
  'Show progress to user.
  With Application
    .ScreenUpdating = True
    .ScreenRefresh
    .ScreenUpdating = False
  End With
  'Convert text to table or create table. Leave empty paragraph beginning the document.
  oRng.MoveStart wdParagraph, 1
  If Len(oRng.Text) > 2 Then
    Set oTbl_1 = oRng.ConvertToTable
  Else
    Set oTbl_1 = oRng.Tables.Add(oRng, 2, 3)
  End If
  'Format table.
  With oTbl_1
    .Style = "Table Grid"
    .Range.NoProofing = True
    With .Rows
      .Add BeforeRow:=oTbl_1.Rows(1)
      .Add BeforeRow:=oTbl_1.Rows(1)
    End With
    With .Rows(1)
      .HeadingFormat = True
      With .Range
      .Cells.Merge
        With .Cells(1).Range
          .ParagraphFormat.Alignment = wdAlignParagraphCenter
          .Text = "Current Keyboard Settings - Custom Key Bindings"
          .Font.Bold = True
        End With
      End With
    End With
    With .Rows(2)
      .HeadingFormat = True
      .Shading.BackgroundPatternColor = wdColorGray10
      .Cells(1).Range.Text = "Category"
      .Cells(2).Range.Text = "Name/Symbol"
      .Cells(3).Range.Text = "Shortcut Key Combination"
    End With
    For lngIndex = 3 To .Rows.Count
      Select Case Left(.Rows(lngIndex).Cells(1).Range.Text, _
             Len(.Rows(lngIndex).Cells(1).Range.Text) - 2)
        Case "1": .Rows(lngIndex).Cells(1).Range.Text = "Command"
        Case "2": .Rows(lngIndex).Cells(1).Range.Text = "Macro"
        Case "3": .Rows(lngIndex).Cells(1).Range.Text = "Font"
        Case "4": .Rows(lngIndex).Cells(1).Range.Text = "BuildingBlock\AutoText"
        Case "5": .Rows(lngIndex).Cells(1).Range.Text = "Style"
        Case "6": .Rows(lngIndex).Cells(1).Range.Text = "Symbol"
      End Select
    Next lngIndex
    'Sort on category.
    .Sort True, 1
  End With
  'Add and format document title.
  With oDoc.Paragraphs(1).Range
    .InsertBefore "Composite Shortcut List"
    .Style = "Title"
  End With
  'Show progress to user.
  With Application
    .ScreenUpdating = True
    .ScreenRefresh
    .ScreenUpdating = False
  End With
  'Add paragraph separator.
  oRng.InsertAfter vbCr
  oRng.Collapse wdCollapseEnd
  'Create the built-in list using the Word command.
  Application.ListCommands ListAllCommands:=0
  'This creates a new active document.
  Set oDocTemp = ActiveDocument
  'Clean up Word 2003 list.
  With Application
    If .Version < 12# Then
      .ScreenUpdating = True
      .ScreenRefresh
      .ScreenUpdating = False
      .StatusBar = "Processing temporary list.  Please wait"
      With oDocTemp.Tables(1)
        .Columns(4).Delete
        For lngIndex = oDocTemp.Tables(1).Rows.Count To 1 Step -1
          Set oRow = oDocTemp.Tables(1).Rows(lngIndex)
          If Len(oRow.Cells(2).Range) = 2 Then
            oRow.Delete
          End If
          DoEvents
        Next lngIndex
      End With
    End If
  End With
  'Get the list (table) and kill the document.
  oDocTemp.Range.Copy
  oDocTemp.Close wdDoNotSaveChanges
  'Ensure the composite list is the active document.
  oDoc.Activate
  'Paste the copied table into the composite list.
  oRng.Paste
  Set oTbl_2 = oDoc.Tables(2)
  'Format table.
  With oTbl_2
    .Style = "Table Grid"
    With .Range
      .Font.Bold = False
      .NoProofing = True
    End With
    .PreferredWidthType = wdPreferredWidthPercent
    .PreferredWidth = 100
    .Rows.Add BeforeRow:=oTbl_2.Rows(1)
     With .Rows(1)
      .HeadingFormat = True
      With .Range
        .Cells.Merge
        With .Cells(1).Range
          .ParagraphFormat.Alignment = wdAlignParagraphCenter
          .Text = "Current Keyboard Settings - Built-in Word Commands"
          .Font.Bold = True
        End With
      End With
    End With
    For lngIndex = 2 To .Rows.Count
      Application.StatusBar = "Processing built-in keybinding " & lngIndex - 1 _
                              & " of " & oTbl_2.Rows.Count - 1 & ".  Please wait."
      With .Rows(lngIndex)
        .Cells(2).Merge .Cells(3)
        .Cells(2).Range.Text = Replace(.Cells(2).Range.Text, vbCr, "")
      End With
      DoEvents
    Next lngIndex
    With .Rows(2)
      .HeadingFormat = True
      .Shading.BackgroundPatternColor = wdColorGray10
      .Cells(1).Range.Text = "Command Name"
      .Cells(2).Range.Text = "Shortcut Key Combination"
    End With
    .Range.Cells.DistributeWidth
  End With
  'Prevent (or try to prevent) a blank page at end of document.
  Do While Len(oDoc.Paragraphs.Last.Previous.Range) = 1
   oDoc.Paragraphs.Last.Previous.Range.Delete
  Loop
  Set oRng = oDoc.Paragraphs.Last.Range
  With oRng
   .Paragraphs(1).SpaceBefore = 0
   .Paragraphs(1).SpaceAfter = 0
   .Paragraphs(1).Range.Font.Size = 1
  End With
lbl_Exit:
  System.Cursor = wdCursorNormal
  Beep
  With Application
    .StatusBar = "Finished!!"
    .ScreenUpdating = True
    .ScreenRefresh
  End With
  Exit Sub
End Sub

Site Note IconSee: Installing Macros for instructions on how to set up and use the macros provided in this Microsoft Word Help & Microsoft Word Tips page.

Due to the large number of built-in Word shortcuts, it may take a while to process and complete the list.  On my system with my shortcuts it takes about 20 seconds.  The actual time will vary depending on your system speed and the number of shortcuts.  Accordingly, so you won't lose hope and think Word has hung up, I've added a process indicator to the status bar.

list all shortcuts 2

Site Note IconNote:  In Word 2003, the built-in list requires additional processing and will take a few seconds longer to complete. 

Conclusion

That's it!! When finished, you will have a complete listing of all of your keyboard shortcut in a document form that you can format to suit your taste and save or print as a reference.

Share Stumbleupon

PAYMENTS/DONATIONS

Click to acces PayPal Verification Service Click to acces PayPal Verification Service

Do you want to make a payment for consulting work or donate to help support this site?

PayPal is a safe, easy way to pay online.

Use the appropriate currency "Donate" button to make a payment or donation.


Search my site or the web using Google Search Engine

Google Search Logo

Or

JustAnswerAsk a Word Expert OnlineSubmit