Skip to content

FindShortcut Method

Description

Returns a shortcut for the specified command.

Syntax

Public Function FindShortcut( _
    ByVal [Command](#) As Long _
) As [KeyBinding](XtremeCommandBars~KeyBinding.md)

Parameters

  • Command: The command ID (ID of the command bar control the shortcut is assigned to) of the shortcut which will be invoked when the accelerator is used.

Return Type

If found, returns a KeyBinding object for the specified command bar control's shortcut.

Example

Find Shortcut From CommandBar ID Sample (Visual Basic)

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 KeyBinding

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

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

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

See Also


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