【发布时间】:2020-02-06 05:13:39
【问题描述】:
我想添加将调用带有参数的子的 KeyBindings。例如:
Sub dummy(text As String)
MsgBox (text)
End Sub
Dim kbNew As KeyBinding
Set kbNew = KeyBindings.Add(KeyCategory:=wdKeyCategoryCommand, Command:="dummy", KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyQ), CommandParameter:="show me")
这不起作用。但是当我使用 MS 文档中的示例时,它正在工作:
Set kbNew = KeyBindings.Add(KeyCategory:=wdKeyCategoryCommand, Command:="FontSize", KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyQ), CommandParameter:="8")
调用不带参数的 sub 也可以:
Sub dummy()
MsgBox ("show me")
End Sub
Set kbNew = KeyBindings.Add(KeyCategory:=wdKeyCategoryCommand, Command:="dummy", KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyQ))
【问题讨论】:
标签: vba parameters ms-word key-bindings