Context Property

Applies To

KeyBinding object, KeyBindings collection object, KeysBoundTo collection object.

Description

Returns an object that represents the storage location of the specified key binding. This property can return a Document, Template, or Application object. Read-only.

Note 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.

See Also

CustomizationContext property, KeysBoundTo property.

Example

This example displays the name of the document or template where the macro named "Macro1" is stored.

Set kb = KeysBoundTo(KeyCategory:=wdKeyCategoryMacro, Command:="Macro1")
MsgBox kb.Context.Name
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.

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