KeyBindings.Add Method
Returns a KeyBinding object that represents a new shortcut key for a macro, built-in command, font, AutoText entry, style, or symbol.
Namespace: Microsoft.Office.Interop.Word
Assembly: Microsoft.Office.Interop.Word (in Microsoft.Office.Interop.Word.dll)
Syntax
'Declaration
Function Add ( _
KeyCategory As WdKeyCategory, _
Command As String, _
KeyCode As Integer, _
ByRef KeyCode2 As Object, _
ByRef CommandParameter As Object _
) As KeyBinding
'Usage
Dim instance As KeyBindings
Dim KeyCategory As WdKeyCategory
Dim Command As String
Dim KeyCode As Integer
Dim KeyCode2 As Object
Dim CommandParameter As Object
Dim returnValue As KeyBinding
returnValue = instance.Add(KeyCategory, _
Command, KeyCode, KeyCode2, CommandParameter)
KeyBinding Add(
WdKeyCategory KeyCategory,
string Command,
int KeyCode,
ref Object KeyCode2,
ref Object CommandParameter
)
Parameters
- KeyCategory
Type: Microsoft.Office.Interop.Word.WdKeyCategory
Required WdKeyCategory. The category of the key assignment.
- Command
Type: System.String
Required String. The command that the specified key combination executes.
- KeyCode
Type: System.Int32
Required Integer. A key you specify by using one of the WdKey constants.
- KeyCode2
Type: System.Object%
Optional Object. A second key you specify by using one of the WdKey constants.
- CommandParameter
Type: System.Object%
Optional Object. Additional text, if any, required for the command specified by Command. For details, see the Remarks section below.
Return Value
Type: Microsoft.Office.Interop.Word.KeyBinding
Remarks
You can use the BuildKeyCode method to create the KeyCode or KeyCode2 argument.
In the following table, the left-hand column contains commands that require a command value, and the right-hand column describes what you must do to specify CommandParameter for each of these commands. (The equivalent action in the Customize Keyboard dialog box (Tools menu) to specifying CommandParameter is selecting an item in the list box that appears when you select one of the following commands in the Commands box.)
If Command is set to |
CommandParameter must be |
---|---|
Borders, Color, or Shading |
A number— specified as text— corresponding to the position of the setting selected in the list box that contains values, where 0 (zero) is the first item, 1 is the second item, and so on |
Columns |
A number between 1 and 45— specified as text— corresponding to the number of columns you want to apply |
Condensed |
A text measurement between 0.1 point and 12.75 points specified in 0.05-point increments (72 points = 1 inch) |
Expanded |
A text measurement between 0.1 point and 12.75 points specified in 0.05-point increments (72 points = 1 inch) |
FileOpenFile |
The path and file name of the file to be opened. If the path isn't specified, the current folder is used. |
Font Size |
A positive text measurement, specified in 0.5-point increments (72 points = 1 inch) |
Lowered, Raised |
A text measurement between 1 point and 64 points, specified in 0.5-point increments (72 points = 1 inch) |
Symbol |
A string created by concatenating a Chr() instruction and the name of a symbol font (for example, Chr(167) & "Symbol") |