Sub Ch_AddMenuItemToshortcutMenu() Dim currMenuGroup As AcadMenuGroup Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
' 查找快捷菜单并将其指定给 ' shortcutMenu 变量 Dim scMenu As AcadPopupMenu Dim entry As AcadPopupMenu For Each entry In currMenuGroup.Menus If entry.ShortcutMenu = True Then Set scMenu = entry End If Next entry
' 向快捷菜单添加菜单项 Dim newMenuItem As AcadPopupMenuItem Dim openMacro As String ' 给宏指定“ESC ESC _open”的 VBA 等价值 openMacro = Chr(3) + Chr(3) + "_open " Dim a As Integer Dim b As String a = Asc("&") b = Chr(95) Set newMenuItem = scMenu.AddMenuItem("", Chr(Asc("&")) + "OpenDWG", openMacro) End Sub
真是太谢谢了 |