2015-11-03 34 views
0

我正在尝试列出所有命令以及它们在Microsoft Word中分配了哪些键。但是我遇到的问题只列出了我所做的宏/命令,而不是那些来自软件的宏;如File SavePrintPreviewAndPrint列出单词中的宏

我目前使用的宏是;

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 

编辑

本宏还没有列出所有宏,我所做的宏/命令。修复此问题的任何帮助将不胜感激

+0

有时它有助于指定CustomizationContext - 保存键绑定(键盘自定义)的文档。如果你想要“一切”,你甚至可能需要处理多个文件。上下文示例:NormalTemplate,ActiveDocument,ActiveDocument.AttachedTemplate。您还需要循环AddIns集合的成员。 –

回答

1

KeyBindings只引用您的自定义快捷方式。

如果你只是希望所有的标准基于词的快捷键的表,那么你要使用:

Application.ListCommands ListAllCommands:=True 

这将打开一个新文档,然后插入一个表与命令名称和KeyString中。

+0

非常感谢你 – Dan

+0

出于兴趣是否有一个原因,它没有列出我的宏的快捷方式。例如,在表格中显示“Normal.NewMacros.UpdateFields”,链接到“Shift + F9”,未指定。 – Dan

+0

我认为它与'ListCommands'有关,只涉及Microsoft创建的快捷方式。但我不确定 –