返回一个 KeysBoundTo 对象,该对象代表指定项的所有组合键。
expression.KeysBoundTo(KeyCategory, Command, CommandParameter)
expression 可选。该表达式返回“应用于”列表中的一个对象。
KeyCategory WdKeyCategory,必需。组合键的类别。
WdKeyCategory 可以是下列 WdKeyCategory 常量之一: |
wdKeyCategoryAutoText |
wdKeyCategoryCommand |
wdKeyCategoryDisable |
wdKeyCategoryFont |
wdKeyCategoryMacro |
wdKeyCategoryNil |
wdKeyCategoryPrefix |
wdKeyCategoryStyle |
wdKeyCategorySymbol |
Command String 类型,必需。命令名称。
CommandParameter Variant 类型,可选。Command 所指定的命令的附加文字(如果有的话)。有关详细信息,请参阅 KeyBindings 对象的 Add 方法的“说明”部分。
本示例显示活动文档附加的模板中为 FileOpen 命令指定的所有组合键。
Dim kbLoop As KeyBinding
Dim strOutput As String
CustomizationContext = ActiveDocument.AttachedTemplate
For Each kbLoop In _
KeysBoundTo(KeyCategory:=wdKeyCategoryCommand, _
Command:="FileOpen")
strOutput = strOutput & kbLoop.KeyString & vbCr
Next kbLoop
MsgBox strOutput
本示例删除“Normal”模板中“Macro1”的所有键盘指定方案。
Dim aKey As KeyBinding
CustomizationContext = NormalTemplate
For Each aKey In _
KeysBoundTo(KeyCategory:=wdKeyCategoryMacro, _
Command:="Macro1")
aKey.Disable
Next aKey