更新时间:2023-11-17 14:33:10
KeyBindings
对象应该可以解决问题.在此处查看示例: http://www.vbaexpress.com/kb/getarticle. php?kb_id = 621
The KeyBindings
object should do the trick. See an example here: http://www.vbaexpress.com/kb/getarticle.php?kb_id=621
' \\ Code for Module1
Option Explicit
Sub AddKeyBinding()
With Application
' \\ Do customization in THIS document
.CustomizationContext = ThisDocument
' \\ Add keybinding to this document Shorcut: Alt+0
.KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKey0), _
KeyCategory:=wdKeyCategoryCommand, _
Command:="TestKeybinding"
End With
End Sub
' \\ Code for Module2
Option Explicit
' \\ Test sub for keybinding
Sub TestKeybinding()
MsgBox "We have a winner", vbInformation, "Succes"
End Sub