| 
			 
Option Explicit 
 
Private Sub Workbook_BeforeClose(Cancel As Boolean) 
     
     
    Run ("DeleteCustomMenu") 
     
End Sub 
 
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean) 
     
    Run ("DeleteCustomMenu") 
    Run ("BuildCustomMenu") 
     
End Sub 
 
 
 
Option Explicit 
 
Private Sub BuildCustomMenu() 
     
    Dim ctrl As CommandBarControl 
    Dim btn As CommandBarControl 
    Dim i As Integer 
     
     
    Set ctrl = Application.CommandBars("Cell").Controls.Add _ 
    (Type:=msoControlPopup, Before:=1) 
    ctrl.Caption = "Insert Shape..." 
     
    For i = 50 To 250 Step 50 
        Set btn = ctrl.Controls.Add 
        btn.Caption = i & " x " & (i / 2) 
        btn.Tag = i 
        btn.OnAction = "InsertShape" 
    Next 
     
End Sub 
 
Private Sub DeleteCustomMenu() 
     
    Dim ctrl As CommandBarControl 
     
     
    For Each ctrl In Application.CommandBars("Cell").Controls 
        If ctrl.Caption = "Insert Shape..." Then ctrl.Delete 
    Next 
     
End Sub 
 
Private Sub InsertShape() 
     
    Dim t As Long 
    Dim shp As Shape 
     
     
    t = CLng(Application.CommandBars.ActionControl.Tag) 
     
     
     
    Set shp = ActiveSheet.Shapes.AddShape _ 
    (msoShapeRectangle, ActiveCell.Left, ActiveCell.Top, t, t / 2) 
     
    Randomize 
    shp.Fill.ForeColor.SchemeColor = Int((56 - 1 + 1) * Rnd + 1) 
     
End Sub 
 
 |