Gruppe
Ereignis
Problem
Wie kann ich im Extras-Menü bei der Anzeige dieser Arbeitsmappe einen eigenen Menüpunkt anzeigen und beim Fensterwechsel wieder ausblenden lassen?
ClassModule: DieseArbeitsmappe
Private Sub Workbook_WindowActivate(ByVal Wn As Excel.Window)
Dim oBar As CommandBar
Dim oPopUp As CommandBarPopup
Dim oBtn As CommandBarButton
Set oBar = Application.CommandBars("Worksheet Menu Bar")
Set oPopUp = oBar.FindControl(ID:=30007)
Set oBtn = oPopUp.Controls.Add
With oBtn
.Caption = "Meldung"
.OnAction = "mnuMeldung"
.Style = msoButtonCaption
End With
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Excel.Window)
Dim oBar As CommandBar
Dim oPopUp As CommandBarPopup
On Error Resume Next
Set oBar = Application.CommandBars("Worksheet Menu Bar")
Set oPopUp = oBar.FindControl(ID:=30007)
oPopUp.Controls("Meldung").Delete
On Error GoTo 0
End Sub
StandardModule: basMain
Sub mnuMeldung()
MsgBox "Ich bin die Meldung!"
End Sub