A bug with ListCommands?

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

A bug with ListCommands?

Post by New Daddy »

Macros - Word Commands - ListCommands is supposed to list all the commands and macros along with their keyboard shortcuts, right?

Then how come the keyboard shortcuts that I assigned to macros do not appear in the list? (They do show up when I print Key Assignments in the Print dialog box.) Is this a bug?

I'm frustrated that there is no comprehensive way to show all my keyboard shortcuts and the functions they perform. Macros - Word Commands - ListCommands is the closest to that, but it doesn't work as it's supposed to.

User avatar
HansV
Administrator
Posts: 78544
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: A bug with ListCommands?

Post by HansV »

According to the documentation, the keyboard shortcuts for macros should be displayed, so it does indeed appear to be a bug if they're not listed.

The following macro should list all custom keyboard assignments in the Immediate window:

Code: Select all

Sub ListKeyboardAssignments()
  Dim kb As KeyBinding
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryMacro Then
      Debug.Print kb.Command, kb.KeyString
    End If
  Next kb
End Sub
Best wishes,
Hans

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

Re: A bug with ListCommands?

Post by New Daddy »

HansV wrote:According to the documentation, the keyboard shortcuts for macros should be displayed, so it does indeed appear to be a bug if they're not listed.

The following macro should list all custom keyboard assignments in the Immediate window:

Code: Select all

Sub ListKeyboardAssignments()
  Dim kb As KeyBinding
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryMacro Then
      Debug.Print kb.Command, kb.KeyString
    End If
  Next kb
End Sub
Your macro doesn't work either. No immediate window pops up.

User avatar
HansV
Administrator
Posts: 78544
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: A bug with ListCommands?

Post by HansV »

The Immediate window is part of the Visual Basic Editor (VBE). You can view it by pressing Ctrl+G in the VBE.

Here is a version that displays a message box:

Code: Select all

Sub ListKeyboardAssignments()
  Dim kb As KeyBinding
  Dim s As String
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryMacro Then
      s = s & vbCrLf & kb.Command & ": " & kb.KeyString
    End If
  Next kb
  If s = "" Then
    MsgBox "No keyboard customizations.", vbInformation
  Else
    MsgBox "Keyboard customizations:" & s, vbInformation
  End If
End Sub
Best wishes,
Hans

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

Re: A bug with ListCommands?

Post by New Daddy »

HansV wrote:The Immediate window is part of the Visual Basic Editor (VBE). You can view it by pressing Ctrl+G in the VBE.

Here is a version that displays a message box:

Code: Select all

Sub ListKeyboardAssignments()
  Dim kb As KeyBinding
  Dim s As String
  For Each kb In KeyBindings
    If kb.KeyCategory = wdKeyCategoryMacro Then
      s = s & vbCrLf & kb.Command & ": " & kb.KeyString
    End If
  Next kb
  If s = "" Then
    MsgBox "No keyboard customizations.", vbInformation
  Else
    MsgBox "Keyboard customizations:" & s, vbInformation
  End If
End Sub
Thanks! I hope Microsoft will fix the bug in the next iteration of Word.