SetKeyNameText Method
Description
Set a custom string description to localize a shortcut key text description.
Syntax
Public Sub SetKeyNameText( _
ByVal [Key](#) As Long, _
ByVal [KeyName](#) As String _
)
Parameters
- Key
Virtual-key of accelerator. Below is a list of virtual keys and codes. You must define these constants in your code, or use the Hex number:
VK_BACK = &H8
VK_TAB = &H9
VK_ESCAPE = &H1B
VK_SPACE = &H20
VK_PRIOR = &H21
VK_NEXT = &H22
VK_END = &H23
VK_HOME = &H24
VK_LEFT = &H25
VK_UP = &H26
VK_RIGHT = &H27
VK_DOWN = &H28
VK_INSERT = &H2D
VK_DELETE = &H2E
VK_MULTIPLY = &H6A
VK_ADD = &H6B
VK_SEPARATOR = &H6C
VK_SUBTRACT = &H6D
VK_DECIMAL = &H6E
VK_DIVIDE = &H6F
VK_F1 = &H70
VK_F2 = &H71
VK_F3 = &H72
VK_F4 = &H73
VK_F5 = &H74
VK_F6 = &H75
VK_F7 = &H76
VK_F8 = &H77
VK_F9 = &H78
VK_F10 = &H79
VK_F11 = &H7A
VK_F12 = &H7B
In addition to the list above, you can change the text for any Numeric or Alphabetic key:
Asc("x")
Replace the x with the character of your choice.
- KeyName
New text that will be associated with the virtual-key specified in the Key parameter.
Remarks
The UseSystemKeyNameText must be False to display the shortcut key descriptions set with SetKeyNameText.
Example
Custom Shortcut Key Description (Visual Basic)
This sample illustrates how to set a custom Shortcut Key description.
'Place these constants in a Module .bas file
Public Const FSHIFT = 4
Public Const FCONTROL = 8
Public Const FALT = 16
Public Const VK_BACK = &H8
Public Const VK_LEFT = &H25
Public Const VK_UP = &H26
Public Const VK_RIGHT = &H27
Public Const VK_DOWN = &H28
Public Const VK_INSERT = &H2D
CommandBars.KeyBindings.Add FCONTROL, VK_HOME, 501
CommandBars.KeyBindings.Add FCONTROL, Asc("C"), 502
CommandBars.KeyBindings.UseSystemKeyNameText = True
CommandBars.KeyBindings.SetKeyNameText VK_HOME, "Press Home Key"
CommandBars.KeyBindings.SetKeyNameText Asc("C"), "Press C Key"
See Also
Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.