Delete Menu Items from a Menu
 
 
 

To remove menu items from a menu, use the Delete method found on the menu item.

WarningIf you delete a menu item, do not call another method or property that would directly or indirectly cause the same CUI file to be loaded again within the same macro. For example, after deleting a menu item, do not use the MenuGroup.Load method or the Preferences.Profiles.ActiveProfile property, or issue a "Menuload" command using the Document.SendCommand method. These items directly or indirectly cause the loading of CUI files. You should only use these methods or properties in a separate macro.

Delete a menu item from a menu

This example adds a menu item to the end of the last menu displayed on the menu bar. It then deletes the menu item.

Sub Ch6_DeleteMenuItem()
	Dim LastMenu As AcadPopupMenu
	Set LastMenu = ThisDrawing.Application.menuBar. _
				Item(ThisDrawing.Application.menuBar.count - 1)


	' Add a menu item
	Dim newMenuItem As AcadPopupMenuItem
	Dim openMacro As String
	' Assign the macro the VB equivalent of "ESC ESC _open "
	openMacro = Chr(3) + Chr(3) + "_open "


	Set newMenuItem = LastMenu.AddMenuItem _
						(LastMenu.count + 1, "Open", openMacro)


	' Remove the menu item from the menu
	newMenuItem.Delete
End Sub