Gruppe
Menue
Problem
Wie kann ich der Format-Symbolleiste beim Öffnen einer bestimmten Arbeitsmappe eine einem Makrzu zugewiesene neue Schaltfläche hinzufügen und diese beim Schließen der Arbeitsmappe wieder löschen?
ClassModule: DieseArbeitsmappe
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call BtnDelete
End Sub
Private Sub Workbook_Open()
Dim oBtn As CommandBarButton
Call BtnDelete
Set oBtn = Application.CommandBars("Formatting").Controls.Add
With oBtn
.Caption = "Befehl"
.FaceId = 2
.OnAction = "MeinBefehl"
.Visible = True
End With
End Sub
StandardModule: basMain
Sub BtnDelete()
On Error GoTo ERRORHANDLER
Application.CommandBars("Formatting") _
.Controls("Befehle").Delete
ERRORHANDLER:
End Sub
Sub MeinBefehl()
MsgBox "Ich bin der Befehl!"
End Sub