Gruppe
Menue
Problem
Dem Zellkontextmenü wird eine Schaltfläche mit benutzerdefiniertem Icon hinzugefügt. Bitte beachten: Der CommandBar-Name des Quell-Icons muss angepasst werden.
StandardModule: Modul1
Sub GetIconFace()
Dim oSource As CommandBarButton
Dim oBtn As CommandBarButton
On Error Resume Next
Application.CommandBars("Cell").Controls("Test").Delete
On Error GoTo 0
On Error GoTo ERRORHANDLER
Set oBtn = Application.CommandBars("Cell").Controls.Add
With oBtn
.Caption = "Test"
.OnAction = "Irgendwas"
.Style = msoButtonIconAndCaption
Set oSource = Application.CommandBars("MyCmdBar").Controls(14)
oSource.CopyFace
oBtn.PasteFace
End With
Exit Sub
ERRORHANDLER:
MsgBox "Das Quell-Icon konnte nicht gefunden werden!"
End Sub
Sub Irgendwas()
MsgBox "Ich bin nur ein Platzhalter"
End Sub
Sub Loeschen()
On Error Resume Next
Application.CommandBars("Cell").Controls("Test").Delete
On Error GoTo 0
End Sub