Word) (KeyBindings 对象

代表当前上下文中的自定义键分配的 键绑定 对象的集合。 在 自定义键盘对话框中进行自定义按键分配方案。

备注

使用 键绑定 属性可返回集合 的键绑定 。 以下示例插入所选内容之后的命令名称和组合的每一项 的键绑定 集合中。

CustomizationContext = NormalTemplate 
For Each aKey In KeyBindings 
 Selection.InsertAfter aKey.Command & vbTab _ 
 & aKey.KeyString & vbCr 
 Selection.Collapse Direction:=wdCollapseEnd 
Next aKey

使用 Add 方法向 键绑定 集合中添加一个 KeyBinding 对象。 下面的示例向活动文档中标题 1 样式的 CTRL + ALT + H 键组合。

CustomizationContext = ActiveDocument 
KeyBindings.Add KeyCategory:=wdKeyCategoryStyle, _ 
 Command:="Heading 1", _ 
 KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyH)

使用 键绑定 (索引),其中索引是索引号,返回一个 KeyBinding 对象。 下面的示例显示与 键绑定 集合中的第一个 KeyBinding 对象相关联的命令。

MsgBox KeyBindings(1).Command

另请参阅

Word 对象模型参考

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。