Word VBA教程:BuildKeyCode方法

为指定的组合键返回唯一的代码。

expression.BuildKeyCode(Arg1, Arg2, Arg3, Arg4)

expression   可选。该表达式返回一个 Application对象。

Arg1  WdKey,必需。用 WdKey 常量指定的一个键。

WdKey 可以是下列 WdKey 常量之一:
wdKeyF
wdKeyF10
wdKeyF12
wdKeyF14
wdKeyF16
wdKeyF3
wdKeyF5
wdKeyF7
wdKeyF9
wdKeyH
wdKeyHyphen
wdKeyInsert
wdKeyK
wdKeyL
wdKeyM
wdKeyN
wdKeyNumeric0
wdKeyNumeric1
wdKeyNumeric2
wdKeyNumeric3
wdKeyNumeric4
wdKeyNumeric5
wdKeyNumeric5Special
wdKeyNumeric6
wdKeyNumeric7
wdKeyNumeric8
wdKeyNumeric9
wdKeyNumericAdd
wdKeyNumericDecimal
wdKeyNumericDivide
wdKeyNumericMultiply
wdKeyNumericSubtract
wdKeyO
wdKeyOpenSquareBrace
wdKeyOption
wdKeyP
wdKeyPageDown
wdKeyPageUp
wdKeyPause
wdKeyPeriod
wdKeyQ
wdKeyR
wdKeyReturn
wdKeyS
wdKeyScrollLock
wdKeySemiColon
wdKeyShift
wdKeySingleQuote
wdKeySlash
wdKeySpacebar
wdKeyT
wdKeyTab
wdKeyU
wdKeyV
wdKeyW
wdKeyX
wdKeyY
wdKeyZ
wdNoKey
wdKey0
wdKey1
wdKey2
wdKey3
wdKey4
wdKey5
wdKey6
wdKey7
wdKey8
wdKey9
wdKeyA
wdKeyAlt
wdKeyB
wdKeyBackSingleQuote
wdKeyBackSlash
wdKeyBackspace
wdKeyC
wdKeyCloseSquareBrace
wdKeyComma
wdKeyCommand
wdKeyControl
wdKeyD
wdKeyDelete
wdKeyE
wdKeyEnd
wdKeyEquals
wdKeyEsc
wdKeyF1
wdKeyF11
wdKeyF13
wdKeyF15
wdKeyF2
wdKeyF4
wdKeyF6
wdKeyF8
wdKeyG
wdKeyHome
wdKeyI
wdKeyJ

Arg2 - Arg4  WdKey,可选。可用下列 WdKey 常量指定。

WdKey 可以是下列 WdKey 常量之一:
wdKeyF
wdKeyF10
wdKeyF12
wdKeyF14
wdKeyF16
wdKeyF3
wdKeyF5
wdKeyF7
wdKeyF9
wdKeyH
wdKeyHyphen
wdKeyInsert
wdKeyK
wdKeyL
wdKeyM
wdKeyN
wdKeyNumeric0
wdKeyNumeric1
wdKeyNumeric2
wdKeyNumeric3
wdKeyNumeric4
wdKeyNumeric5
wdKeyNumeric5Special
wdKeyNumeric6
wdKeyNumeric7
wdKeyNumeric8
wdKeyNumeric9
wdKeyNumericAdd
wdKeyNumericDecimal
wdKeyNumericDivide
wdKeyNumericMultiply
wdKeyNumericSubtract
wdKeyO
wdKeyOpenSquareBrace
wdKeyOption
wdKeyP
wdKeyPageDown
wdKeyPageUp
wdKeyPause
wdKeyPeriod
wdKeyQ
wdKeyR
wdKeyReturn
wdKeyS
wdKeyScrollLock
wdKeySemiColon
wdKeyShift
wdKeySingleQuote
wdKeySlash
wdKeySpacebar
wdKeyT
wdKeyTab
wdKeyU
wdKeyV
wdKeyW
wdKeyX
wdKeyY
wdKeyZ
wdNoKey
wdKey0
wdKey1
wdKey2
wdKey3
wdKey4
wdKey5
wdKey6
wdKey7
wdKey8
wdKey9
wdKeyA
wdKeyAlt
wdKeyB
wdKeyBackSingleQuote
wdKeyBackSlash
wdKeyBackspace
wdKeyC
wdKeyCloseSquareBrace
wdKeyComma
wdKeyCommand
wdKeyControl
wdKeyD
wdKeyDelete
wdKeyE
wdKeyEnd
wdKeyEquals
wdKeyEsc
wdKeyF1
wdKeyF11
wdKeyF13
wdKeyF15
wdKeyF2
wdKeyF4
wdKeyF6
wdKeyF8
wdKeyG
wdKeyHome
wdKeyI
wdKeyJ

VBA示例

本示例为 Organizer 命令指定组合键 Alt+F1。


CustomizationContext = NormalTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(Arg1:=wdKeyAlt, _
    Arg2:=wdKeyF1), KeyCategory:=wdKeyCategoryCommand, _
    Command:="Organizer"

本示例从 Normal 模板中删除 Alt+F1 组合键。


CustomizationContext = NormalTemplate
FindKey(BuildKeyCode(Arg1:=wdKeyAlt, Arg2:=wdKeyF1)).Clear

本示例显示 F1 指向的命令。


CustomizationContext = NormalTemplate
MsgBox FindKey(BuildKeyCode(Arg1:=wdKeyF1)).Command

Word VBA教程

Word VBA参考教程:目录1 Word VBA参考教程:目录2
Word VBA参考教程:目录3 Word VBA参考教程:目录4
Word VBA参考教程:目录5 Word VBA参考教程:目录6
Word VBA参考教程:目录7 Word VBA参考教程:目录8
Word VBA参考教程:目录9 Word VBA参考教程:目录10
版权所有 © 中山市飞娥软件工作室 证书:粤ICP备09170368号