Re: Neue Symbolleiste per VBA
08.07.2002 19:26:23
Silvio
+++++++++++++++++++++++++++++
'DIESEN CODE in den VB-Editor
+++++++++++++++++++++++++++++
Private Sub Workbook_Open()
'eigene Symbolleiste anlegen für die Monate
Dim symb As CommandBar
Dim i As Integer
On Error Resume Next' Erstellen der leeren Symbolleiste für die Monatsverwaltung
Set symb = Application.CommandBars.Add("Monate", _
Position:=msoBarTop, Temporary:=True)
With symb
.Left = 0
.Visible = True
End With
Set Symbol = Application.CommandBars("Monate").Controls _
.Add(Type:=msoControlButton)
With Symbol
.Style = msoButtonIconAndCaption
.FaceId = 2634
.Caption = "Januar"
.TooltipText = "Bla Bla Bla"
.BeginGroup = True
'führe das Makro mit dem Namen Januar() aus...
.OnAction = "Januar"
End With
Set Symbol = Application.CommandBars("Monate").Controls _
.Add(Type:=msoControlButton)
With Symbol
.Style = msoButtonIconAndCaption
.FaceId = 1016
.Caption = "Februar"
.TooltipText = "bla bla bla"
.BeginGroup = True
'führe das Makro mit dem Namen Februar() aus...
.OnAction = "Februar"
End With
Set Symbol = Application.CommandBars("Monate").Controls _
.Add(Type:=msoControlButton)
With Symbol
.Style = msoButtonIconAndCaption
.FaceId = 462
.Caption = "März"
.TooltipText = "Bla bla Bla"
'führe das Makro mit dem Namen Maerz() aus...
.OnAction = "Maerz"
End With
End Sub
Private Sub Workbook_Activate()
'Symbolleiste bim Aktivieren der Mappe einblenden
On Error Resume Next
Application.CommandBars("Monate").Enabled = True
End Sub
Private Sub Workbook_Deactivate()
'Symbolleiste beim Wechseln auf anderes Blatt ausblenden
On Error Resume Next
Application.CommandBars("Monate").Enabled = False
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Beim Schließen der Datei die Symbolleiste wieder entfernen
On Error Resume Next
Application.CommandBars("Monate").Delete
End Sub
++++++++++++++++++++++++++++++
Diesen Code in ein Modul
++++++++++++++++++++++++++++++
'PS: Hier wird definiert was passiert wenn
'auf die Schaltflächen z.B. Maerz gedrückt wird
'Siehe auch "Diese Arbeitsmappe-Code unter ".OnAction ="
Sub Januar()
MsgBox "Alles klar Januar!"
End Sub
Sub Februar()
MsgBox "Alles klar Februar!"
End Sub
Sub Maerz()
MsgBox "Alles klar!"
End Sub
Ich hoffe das hilft weiter
Bye Silvio