AW: Symbolleiste einfügen
26.07.2006 08:10:23
Matthias
Hallo Al,
ich würde die Symbolleiste zur Laufzeit (beim aktivieren der Mappe) mit VBA erstellen und beim Deaktivieren der Mappe wieder löschen:
In DieseArbeitsmappe:
Private Sub Workbook_Activate()
BaueSymbolleiste
End Sub
Private Sub Workbook_Deactivate()
LöscheSymbolleiste
End Sub
In ein allgemeines Modul:
Const SymbolleistenName = "Meine Symbolleiste"
Sub LöscheSymbolleiste()
On Error Resume Next 'falls nicht vorhanden
Application.CommandBars(SymbolleistenName).Delete 'löschen, falls vorhanden
End Sub
Sub BaueSymbolleiste()
Dim cB As CommandBar
Dim CBC As Object
On Error Resume Next
Application.CommandBars(SymbolleistenName).Delete 'löschen, falls vorhanden
Set cB = Application.CommandBars.Add(Name:=SymbolleistenName, _
temporary:=True, Position:=msoBarTop, MenuBar:=msoBarTypeNormal)
On Error GoTo 0
cB.Visible = True
cB.Protection = msoBarNoMove
cB.Enabled = True
Set CBC = cB.Controls.Add(Type:=msoControlButton)
With CBC
.Style = msoButtonCaption
.BeginGroup = False
.Caption = "Makro Eins"
.OnAction = "Makro1"
.TooltipText = "Makro 1 starten"
End With
Set CBC = cB.Controls.Add(Type:=msoControlButton)
With CBC
.Style = msoButtonIconAndCaption
.FaceId = 2
.BeginGroup = True
.Caption = "Makro Zwei"
.OnAction = "Makro2"
.TooltipText = "Makro 2 starten"
End With
Set CBC = cB.Controls.Add(Type:=msoControlButton)
With CBC
.Style = msoButtonIcon
.FaceId = 12
.BeginGroup = False
.Caption = "Makro Drei"
.OnAction = "Makro3"
.TooltipText = "Makro 3 starten"
End With
'usw usf.
End Sub
' TESTMAKROS:
Sub Makro1()
MsgBox "Hier Makro 1"
End Sub
Sub Makro2()
MsgBox "Hier Makro 2"
End Sub
Sub Makro3()
MsgBox "Hier Makro 3"
End Sub
Gruß Matthias