这里是我以前一个project的部分code,
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not Cancel Then
RemoveMenu
End If
End Sub
Private Sub Workbook_Open()
CreateMenu
End Sub
Sub CreateMenu()
Dim CBPop As CommandBarControl
Dim i As Integer
'Add "Simulate" menu to main menu bar and chart menu bar
AddSimulateMenu "Worksheet Menu Bar"
AddSimulateMenu "Chart Menu Bar"
End Sub
Sub AddSimulateMenu(MenuBarName As String)
Dim CBPop As CommandBarControl
Dim CBCtl