我正在嘗試列出所有命令以及它們在Microsoft Word中分配了哪些鍵。但是我遇到的問題只列出了我所做的宏/命令,而不是那些來自軟件的宏;如File Save
或PrintPreviewAndPrint
。列出單詞中的宏
我目前使用的宏是;
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
編輯
本宏還沒有列出所有宏,我所做的宏/命令。修復此問題的任何幫助將不勝感激
有時它有助於指定CustomizationContext - 保存鍵綁定(鍵盤自定義)的文檔。如果你想要「一切」,你甚至可能需要處理多個文件。上下文示例:NormalTemplate,ActiveDocument,ActiveDocument.AttachedTemplate。您還需要循環AddIns集合的成員。 –