Application![]() |
该对象为 KeyBinding 对象组成的集合,这些元素对象代表当前上下文中自定义键盘布局。在“自定义键盘”对话框中进行自定义键盘布局。
可用 KeyBindings 属性返回 KeyBindings 集合。下例在选定内容后插入 KeyBindings 集合中每个项目的命令名称和组合键。
CustomizationContext = NormalTemplate
For Each aKey In KeyBindings
Selection.InsertAfter aKey.Command & vbTab _
& aKey.KeyString & vbCr
Selection.Collapse Direction:=wdCollapseEnd
Next aKey
可用 Add 方法在 KeyBindings 集合中添加一个 KeyBindings 对象。下列示例为活动文档中的“标题 1”样式添加 Ctrl+Alt+H 组合键。
CustomizationContext = ActiveDocument
KeyBindings.Add KeyCategory:=wdKeyCategoryStyle, _
Command:="Heading 1", _
KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyH)
可用 KeyBindings (index) 返回一个 KeyBinding 对象,此处 index 为索引号。下例显示 KeyBindings 集合中第一个 KeyBinding 对象对应的命令。
MsgBox KeyBindings(1).Command