Message 1 of 4
How to create a menu item with vba
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi
I found this function to create menu:
Public Sub AddMenus()
'Jonathan D. Kriek
Dim currMenuGroup As AcadMenuGroup
Dim newMenu As AcadPopupMenu
Dim newMenuItem As AcadPopupMenuItem
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
On Error Resume Next
'Assign new menu
Set newMenu = currMenuGroup.Menus.Item("TrinityTools")
'If menu doesn't exist then add it
If newMenu Is Nothing Then
Set newMenu = currMenuGroup.Menus.Add("TrinityTools")
End If
'Check if Menu is displayed on MenuBar
If Not newMenu.OnMenuBar Then
'Add the eBLoader macro to the menu
Set newMenuItem = newMenu.AddMenuItem(newMenu.count + 1, _
"Release To eB", "-vbarun eBLoader ")
newMenuItem.HelpString = "Release To eB"
'Add the DrawingTypeLoad macro to the menu
Set newMenuItem = newMenu.AddMenuItem(newMenu.count + 1, _
"Set Drawing Type", "-vbarun DrawingTypeLoad ")
newMenuItem.HelpString = "Set Drawing Type"
'Display the menu on the menu bar
newMenu.InsertInMenuBar (ThisDrawing.Application.MenuBar.count + 1)
End If
'Save menu
currMenuGroup.Save (acMenuFileCompiled)
End Sub
but after run it I cannot see a new menu.