AW: Code in Add in mit Buttons verpacken
10.09.2009 10:03:37
Tino
Hallo,
sollte ich Deine Frage richtig verstanden haben, könnte es so gehen.
Öffne eine leer Exceldatei.
kommt als Code in DieseArbeitsmappe
Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("cell").Reset
End Sub
Private Sub Workbook_Open()
Dim Auswahl As CommandBarPopup
With Application.CommandBars("cell")
.Reset
Set Auswahl = .Controls.Add(Type:=msoControlPopup, Before:=1, Temporary:=True)
End With
With Auswahl
.BeginGroup = True
.Caption = "&Meine Makros"
.TooltipText = "Meine Makrosammlung"
End With
'Für Dein Makro1 ****************************
With Auswahl.Controls.Add
.OnAction = "NA_raus" 'Makro aus Modul
.Caption = "NA_raus" 'Angezeigter Text
.FaceId = 133 'Symbol
End With
'Für Dein Makro2 ****************************
With Auswahl.Controls.Add
.OnAction = "Noch_ein_Makro"
.Caption = "Noch ein Makro"
.FaceId = 133
End With
'usw...
End Sub
Erstelle ein Modul, in dieses Modul kommen Deine Makros.
Sub NA_raus()
Dim rng As Range, cell As Range, fmla As String
Set rng = Cells.SpecialCells(xlCellTypeFormulas, 16)
For Each cell In rng
fmla = Right(cell.Formula, Len(cell.Formula) - 1)
cell.Formula = "=if(iserror(" & fmla & "), """"," & fmla & ")"
Next
End Sub
Sub Noch_ein_Makro()
MsgBox "huhu"
End Sub
Diese Exceldatei speicherst Du als Addin und schließen.
In einer Exceldatei bindest Du nun noch dieses Addin ein.
Beim öffnen einer Exceldatei, sollte wenn Du alles richtig gemacht hast, bei rechtsklick in eine beliebige Zelle dieses Menü mit vorhanden sein.

Gruß Tino