Once you've loaded a menu group, its corresponding MenuGroup object is added to the Menu-Groups collection. A MenuGroup object contains two collections, PopupMenus and Toolbars. All the menus within a menu group are members of the PopupMenus collection, and all the toolbars are members of the Toolbars collection. You access these two collections via the Menus and Toolbars properties of the MenuGroup object with the following syntax:
Set PopupMenusCollection = MenuGroupObject.Menus Set ToolbarsCollection = MenuGroupObject.Toolbars
The following code sample sets a reference to the MenuGroup object representing the ACAD menu group if it's loaded into the current session. It then displays a list of each of the menus and toolbars that make up this menu group. Here I used the NameNoMnemonic property of the menus to display their names rather than the Name property because I didn't want to show all the accelerator keys and hot keys.
On Error Resume Next
Set objMenuGroup = ThisDrawing.Application.MenuGroups.Item("ACAD")
If objMenuGroup Is Nothing Then
MsgBox "ACAD menu group is not loaded" Exit Sub
End If strMenusAndToolbars = _
"The ACAD menu group comprises the following menus: " & vbCrLf
For Each objPopupMenu In objMenuGroup.Menus strMenusAndToolbars = strMenusAndToolbars & _
objPopupMenu.NameNoMnemonic & ", "
Next strMenusAndToolbars = strMenusAndToolbars & vbCrLf & vbCrLf & _ " and the following toolbars: " & vbCrLf
For Each objToolBar In objMenuGroup.Toolbars strMenusAndToolbars = strMenusAndToolbars & objToolBar.Name & ", "
Figure 16-4 shows the result of this code. As you can see, the File, Edit, and View menus (as well as the Draw, Modify, and Dimension toolbars) belong to this group. Note that many of these menus and toolbars aren't normally visible when you use the AutoCAD interface.
Was this article helpful?