如何给动态生成的ActiveBar加快捷键
如题,我用aTool.ShortCuts = "Alt+N"提示 “对象 shortcuts 的方法 itool 失败”
请问我应该怎么添加,谢谢
[解决办法]
常用F1对你会有很大的帮助!!!
Sets or returns a string array of shortcut keys for the tool.
Syntax
[form!]Tool.ShortCuts[ = value As Variant ]
Remarks
The first element in the array will be displayed on the menu as the default shortcut.
To assign values to the ShortCuts property you must first declare a string array as a New shortcut type. You can then use the shortcut value property to assign values to the array items. You can use "Alt", "Control" and "Shift" in the string to specify the <Alt>, <Control> and <Shift> keys respectively. You must spell out the words "Control" and "Shift". The shortcut must be specified in Alt, Control, Shift order. Entering "Control+Alt+N" will generate an error. There cannot by any spaces within the string.
To clear a shortcut, user the shortcut clear method.
Example
Assign Shortcuts:
Private Sub CreateStandardTools()
Dim oTool As Tool
Dim saShortcuts(4) As New ShortCut
' Shortcuts
saShortcuts(0).Value = "Control+Shift+A"
saShortcuts(1).Value = "Control+B"
saShortcuts(2).Value = "Alt+Control+C"
saShortcuts(3).Value = "Alt+O"
saShortcuts(4).Value = "F8"
Set oTool = ActiveBar2.Tools.Add(GetUniqueToolID(), "Open")
oTool.ControlType = ddTTButton
oTool.Caption = "&Open"
oTool.Shortcuts = saShortcuts
End Sub
Clear Shortcut:
Dim saShortcuts(4) As New ShortCut
' Shortcuts
saShortcuts(0).Clear
saShortcuts(1).Clear
saShortcuts(2).Clear
saShortcuts(3).Clear
saShortcuts(4).Clear
ActiveBar2.Tools("Open").Shortcuts = saShortcuts
Data Type
shortcut