KeyBinding.Context property (Word)

Returns an Object that represents the storage location of the specified key binding. Read-only.

Syntax

expression. Context

expression A variable that represents a 'KeyBinding' object.

Remarks

This property can return a Document, Template, or Application object. Built-in key assignments (for example, CTRL+I for Italic) return the Application object as the context. Any key bindings you add will return a Document or Template object, depending on the customization context in effect when the KeyBinding object was added.

Example

This example adds the F2 key to the Italic command and then uses the For Each...Next loop to display the keys assigned to the Italic command along with the context.

Dim kbLoop As KeyBinding 
 
CustomizationContext = NormalTemplate 
KeyBindings.Add KeyCategory:=wdKeyCategoryCommand, _ 
 Command:="Italic", KeyCode:=wdKeyF2 
For Each kbLoop In _ 
 KeysBoundTo(KeyCategory:=wdKeyCategoryCommand, _ 
 Command:="Italic") 
 MsgBox kbLoop.KeyString & vbCr & kbLoop.Context.Name 
Next kbLoop

See also

KeyBinding Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.