How to create a menu item with vba

How to create a menu item with vba

m09366023695
Enthusiast Enthusiast
557 Views
3 Replies
Message 1 of 4

How to create a menu item with vba

m09366023695
Enthusiast
Enthusiast

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.

0 Likes
558 Views
3 Replies
Replies (3)
Message 2 of 4

seabrahenrique
Advocate
Advocate

Hello,

 

Have you consider to use the "CUI" command to build your menu?

 

I guess is a better solution than build by a code.

 

I hope can help u.

0 Likes
Message 3 of 4

m09366023695
Enthusiast
Enthusiast

I writing a macro and need to a menu to show user.

0 Likes
Message 4 of 4

Ed__Jobe
Mentor
Mentor

Menus are not used very much anymore. By default, it is off and only the ribbon shows. Do you have MENUBAR set to 1?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes