我正在尝试列出所有命令以及它们在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集合的成员。 –