Gruppe
Menue
Problem
Wie kann ich in XL8 beim Laden einer Arbeitsmappe der Excel-Menüleiste zwei Befehle hinzufügen, die beim Schließen der Mappe wieder gelöscht werden sollen?
ClassModule: DieseArbeitsmappe
Private Sub Workbook_Open()
Dim oBar As CommandBar
Dim oBtn As CommandBarButton
Set oBar = Application.CommandBars("Worksheet Menu Bar")
On Error Resume Next
oBar.Controls("Test1").Delete
oBar.Controls("Test2").Delete
On Error GoTo 0
Set oBtn = oBar.Controls.Add( _
Type:=msoControlButton, _
before:=CB.Controls.Count, _
ID:=59, _
temporary:=True)
With oBtn
.Caption = "Test1"
.OnAction = "Makro1"
End With
Set oBtn = oBar.Controls.Add( _
Type:=msoControlButton, _
before:=CB.Controls.Count, _
ID:=276, _
temporary:=True)
With oBtn
.Caption = "Test2"
.OnAction = "Makro2"
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
With Application.CommandBars("Worksheet Menu Bar")
.Controls("Test1").Delete
.Controls("Test2").Delete
End With
On Error GoTo 0
End Sub