例如:
Sub xx()
With Application.CommandBars("Cell")
.Reset
.Controls.Add(Type:=msoControlButton, before:=2).Caption = "巨集1"
.Controls("巨集1").OnAction = "yy"
End With
End Sub
在右鍵的第二項增加一個執行巨集1的項目,該項目指向名為"yy"的巨集
離開時要移除
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("cell").Reset
End Sub作者: cchaha_captain 時間: 2011-9-20 00:10