To delete a menu item from a PopupMenu object, you simply use the Delete method:
You can use the following macro to delete menus on the menu bar. The user specifies which menu to delete. The code then iterates through the menu items in that menu and asks the user if he or she wants to delete each item.
Help Apress Creates
Public Sub DeleteMenu() Dim objMenu As AcadPopupMenu Dim objMenuItem As AcadPopupMenuItem Dim strDeleteMenuName As String Dim strMenuName As String strDeleteMenuName = InputBox("Enter name of Menu to remove: ") If strDeleteMenuName = "" Then Exit Sub
On Error Resume Next
Set objMenu = ThisDrawing.Application.MenuBar.Item(strDeleteMenuName) If objMenu Is Nothing Then
MsgBox "Menu is not on the menu bar" Exit Sub End If
For Each objMenuItem In objMenu strMenuName = objMenuItem.Caption
If strMenuName = "" Then strMenuName = "Separator"
If MsgBox("Delete " & strMenuName, vbYesNo, _ "Confirm deletion of a MenuItem") = _ vbYes Then objMenuItem.Delete End If
Next End Sub
Was this article helpful?