UIObject.AccelTables Property

Visio Automation Reference

Returns the AccelTables collection of a UIObject object. Read-only.

Version Information
 Version Added:  Visio 4.0

Syntax

expression.AccelTables

expression   A variable that represents a UIObject object.

Return Value
AccelTables

Remarks

If a UIObject object represents menu items and accelerators (for example, if you used the BuiltInMenus property of an Application object to retrieve the UIObject object), its AccelTables collection represents tables of accelerator keys for that UIObject object.

To retrieve accelerators for a particular window context, for example, the drawing window, use the ItemAtID property of an AccelTables collection. If a window context does not include accelerators, it has no AccelTables collection. Valid window context IDs are declared in VisUIObjSets in the Visio type library.

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the AccelTables property to delete an accelerator key from a built-in menu.

To restore the built-in menus in Microsoft Office Visio after you run this macro, call the ThisDocument.ClearCustomMenus method.

Visual Basic for Applications
  
Public Sub AccelTables_Example()
 
    Dim vsoUIObject As Visio.UIObject 
    Dim vsoAccelTable As Visio.AccelTable 
    Dim vsoAccelItems As Visio.AccelItems 
    Dim vsoAccelItem As Visio.AccelItem 
    Dim intCounter As Integer
'Retrieve the UIObject object for the copy of the built-in menus.
Set vsoUIObject = Visio.Application.BuiltInMenus

'Set vsoAccelTable to the drawing menu set.
Set vsoAccelTable = vsoUIObject.AccelTables.ItemAtID(visUIObjSetDrawing) 

'Retrieve the accelerator items collection.
Set vsoAccelItems = vsoAccelTable.AccelItems 

'Retrieve the accelerator item for the Visual Basic Editor.
'To do this, we must iterate through the collection
'and locate the item we want to manipulate.
'The item can be identified either by checking
'the CmdNum property or by checking for the specific key.
'Because checking for the key requires looking at the Alt,
'Control, Shift, and Key properties, it is better to use the
'CmdNum property. Because we retrieved the built-in menus,
'we know that we can find the accelerator.
For intCounter = 0 To vsoAccelItems.Count - 1 
    Set vsoAccelItem = vsoAccelItems.Item(intCounter) 
    If vsoAccelItem.CmdNum = Visio.visCmdToolsRunVBE Then
Exit For 

End If  
Next intCounter 

'Delete the accelerator. 
vsoAccelItem.Delete 

'Tell Visio to use the new UI. 
ThisDocument.SetCustomMenus vsoUIObject 

End Sub

See Also