2015-11-03 69 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創建的快捷方式。但我不確定 –