Ah, in der Tat. Verstehe wo Du bzw wie Du das meinst.
Entferne das AddIn mal.
Schließe Excel.
Öffne Dein AddIn zum ändern (Rechtsklick -> öffnen)
Hinterlege folgendes im Workbook_Open()-Event Deines AddIn.
Option Explicit
Private Sub Workbook_Open()
Call CreateMenuBar
End Sub
Speichere.
Folgendes in ein Modul:
Option Explicit
Dim cControl As CommandBarButton
Public Sub CreateMenuBar()
On Error Resume Next 'Just in case
'Delete any existing menu item that may have been left.
Application.CommandBars("Worksheet Menu Bar").Controls("Gruppe-Franz").Delete
'Add the new menu item and Set a CommandBarButton Variable to it
Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add
'Work with the Variable
With cControl
.Caption = "Franz-Makro"
.Style = msoButtonCaption
.OnAction = "DeinProzedurName"
'Macro stored in a Standard Module
End With
On Error GoTo 0
End Sub
Public Sub DeleteMenuBar()
On Error Resume Next 'In case it has already gone.
Application.CommandBars("Worksheet Menu Bar").Controls("Gruppe-Franz").Delete
On Error GoTo 0
End Sub
Speichere.
Binde das AddIn wieder ein und prüfe, ob Du oben im Menüband eine registertkarte+Gruppe+Button findest.
Im optimalen Fall, hast Du die Prozedur "CreateMenuBar" an Deine Bedürftnisse angepasst und steuerst Dein Makro schon via .OnAction an.
gruß
Marco
|