AW: Makro allen Mappen zur Verfügung stellen
20.04.2006 13:02:09
Matthias
Hallo kn,
am besten du erstellst die Symbolleiste beim Öffnen des Add-Ins:
DieseArbeitsmappe:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
LöscheSymbolleiste
End Sub
Private Sub Workbook_Open()
BaueSymbolleiste
End Sub
Modul1:
Option Explicit
Const SymbolleistenName = "Meine Symbolleiste"
Sub LöscheSymbolleiste()
On Error Resume Next 'falls nicht vorhanden
Application.CommandBars(SymbolleistenName).Delete 'löschen, falls vorhanden
On Error GoTo 0
End Sub
Sub BaueSymbolleiste()
Dim cB As CommandBar
Dim CBC As CommandBarButton
On Error Resume Next
Application.CommandBars(SymbolleistenName).Delete 'löschen, falls vorhanden
On Error GoTo 0
Set cB = Application.CommandBars.Add(Name:=SymbolleistenName, _
temporary:=True, Position:=msoBarTop)
cB.Visible = True
'erster Button
Set CBC = cB.Controls.Add(Type:=msoControlButton)
With CBC
.Style = msoButtonIcon
.Caption = "Speichern"
.OnAction = "Makro1"
.TooltipText = "Makro1 aufrufen"
.FaceId = 3
End With
'zweiter Button
Set CBC = cB.Controls.Add(Type:=msoControlButton)
With CBC
.Style = msoButtonIconAndCaption
.BeginGroup = True
.Caption = "Speichern"
.OnAction = "Makro2"
.TooltipText = "Makro2 aufrufen"
.FaceId = 4
End With
'kann fortgesetzt werden!
End Sub
'Demo-Prozeduren:
Sub Makro1()
MsgBox "Makro1"
End Sub
Sub Makro2()
MsgBox "Makro2"
End Sub
Grüße,
Matthias