键绑定对象 (Word)KeyBindings object (Word)

KeyBinding 对象的集合, 这些对象代表当前上下文中的自定义键分配方案。A collection of KeyBinding objects that represent the custom key assignments in the current context. “自定义键盘” 对话框中进行自定义按键分配方案。Custom key assignments are made in the Customize Keyboard dialog box.

备注Remarks

使用**键绑定** 属性返回键绑定集合。Use the KeyBindings property to return the KeyBindings collection. 以下示例插入所选内容之后的命令名称和组合的每一项 的键绑定 集合中。The following example inserts after the selection the command name and key combination for each item in the KeyBindings collection.

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

使用add方法可将KeyBinding对象添加到键绑定集合中。Use the Add method to add a KeyBinding object to the KeyBindings collection. 下面的示例向活动文档中标题 1 样式的 CTRL + ALT + H 键组合。The following example adds the CTRL+ALT+H key combination to the Heading 1 style in the active document.

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

使用键绑定(索引), 其中索引是索引号, 返回一个KeyBinding对象。Use KeyBindings (Index), where Index is the index number, to return a single KeyBinding object. 下面的示例显示与 键绑定 集合中的第一个 KeyBinding 对象相关联的命令。The following example displays the command associated with the first KeyBinding object in the KeyBindings collection.

MsgBox KeyBindings(1).Command

另请参阅See also

Word 对象模型参考Word Object Model Reference

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.