Skip to content

KeyBindings Collection

Description

Represents a collection of key bindings (accelerator keys) associated with various commands in command bars.

For a list of all members defined in this module, see KeyBindings Members.

Object Model

KeyBindings Object Model
Parameter Cross Reference
KeyBinding Object Model

Example

KeyBindings Sample (Visual Basic)

This example shows how to find a shortcut by CommandBar Control ID and how to iterate through all shortcuts.

Dim KeyBindings As KeyBindings

Set KeyBindings = CommandBars.KeyBindings

KeyBindings.AddShortcut ID_FILE_NEW, "Ctrl+N"
KeyBindings.AddShortcut ID_FILE_OPEN, "Ctrl+O"
KeyBindings.AddShortcut ID_FILE_SAVE, "Ctrl+S"
KeyBindings.AddShortcut ID_EDIT_CUT, "Ctrl+X"
KeyBindings.AddShortcut ID_EDIT_COPY, "Ctrl+C"

Dim keyShortcut As IKeyBinding

' Finds a shortcut by commandbar ID
keyShortcut = KeyBindings.FindShortcut(ID_FILE_NEW)

If Not keyShortcut Is Nothing Then
    Debug.Print "The commandbar control that uses this shortcut has an ID of " & keyShortcut.Command
    Debug.Print "The shortcut text for commandbar control with ID of " & keyShortcut.Command & " is " & keyShortcut.ShortcutText
End If

For Each keyShortcut In KeyBindings
    Debug.Print "The commandbar control that uses this shortcut has an ID of " & keyShortcut.Command
    Debug.Print "The shortcut text for commandbar control with ID of " & keyShortcut.Command & " is " & keyShortcut.ShortcutText
Next

See Also

KeyBindings Members


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.