PDA

View Full Version : add a shortcut menu to excel



lior03
11-13-2007, 02:49 AM
hello all
during the course of my excel development hobby i inventerd a lot of menu
shortcuts.i want to orgnize all of them under one shortcutmenu(suppose to be first item in my shortcut menu).by clicking this menu a list with all my shortcuts will appear.

On Error Resume Next
Dim MenuItem
CommandBars("Cell").Controls("iris").Delete
Dim NewItem As CommandBarControl
Set NewItem = CommandBars("Cell").Controls.Add(Type:=msoControlPopup)
Set Submenuitem = MenuItem.Controls.Add _
(Type:=msoControlButton)
With Submenuitem
.Caption = "add a new worksheet"
.FaceId = 420
.OnAction = "addworksheet5"
.BeginGroup = True
End With


i know it's possible i saw some excel add-in having the same feature.
thanks

Bob Phillips
11-13-2007, 03:05 AM
On Error Resume Next
Dim NewItem As CommandBarPopup
Dim SubMenuItem As CommandBarButton
CommandBars("Cell").Controls("iris").Delete
Set NewItem = CommandBars("Cell").Controls.Add(Type:=msoControlPopup, before:=1)
NewItem.Caption = "iris"
Set SubMenuItem = NewItem.Controls.Add(Type:=msoControlButton)
With SubMenuItem
.Caption = "add a new worksheet"
.FaceId = 420
.OnAction = "addworksheet5"
.BeginGroup = True
End With
Set SubMenuItem = NewItem.Controls.Add(Type:=msoControlButton)
With SubMenuItem
.Caption = "delete active worksheet"
.FaceId = 420
.OnAction = "deleteworksheet5"
End With