AW: Symbolleisten ändern
23.07.2003 20:24:11
Matthias G.
Hallo Heinz,
Am besten ist es, die Sysmbolleiste jedesmal beim Öffnen der Datei neu zusammenzubauen und vor dem Schließen der Mappe zu löschen. Sonst hast Du u.a. das Problem, dass bei Änderung des Dateinamens die zugeordneten Makros nicht gefunden werden.
Beispielcode:
Sub BaueSymbolleiste()
Dim cb As CommandBar
Dim CBC As CommandBarButton
Dim i%
On Error Resume Next
Set cb = Application.CommandBars.Add(Name:="Meine Symbolleiste", _
temporary:=True, Position:=msoBarTop)
On Error GoTo 0
If Application.CommandBars("Meine Symbolleiste").Visible = False Then
cb.Visible = True
For i = 1 To 5
Set CBC = cb.Controls.Add(Type:=msoControlButton)
With CBC
.Style = msoButtonIconAndCaption
Select Case i
Case 1
.Caption = "Speichern"
.OnAction = "PlanSpeichern"
.TooltipText = "Dienstplan speichern"
.FaceId = 3
.Style = msoButtonIconAndCaption
.Visible = True
Case 2
.BeginGroup = True
.Caption = "Drucken"
.OnAction = "PlanDrucken"
.TooltipText = "Dienstplan drucken"
.FaceId = 4
.Style = msoButtonIconAndCaption
.Visible = True
Case 3
.Caption = "Seitenansicht"
.OnAction = "PlanSeitenansicht"
.TooltipText = "Seitenansicht"
.FaceId = 109
.Style = msoButtonIconAndCaption
.Visible = True
Case 4
.BeginGroup = True
.Caption = "Vergrößern"
.OnAction = "ZoomIn"
.TooltipText = "Vergrößern"
.FaceId = 444
.Style = msoButtonIcon
Case 5
.Caption = "Verkleinern"
.OnAction = "ZoomOut"
.TooltipText = "Verkleinern"
.FaceId = 445
.Style = msoButtonIcon
End Select
End With
Next i
End If
End Sub
Sub LöscheSymbolleiste()
Application.CommandBars("Meine Symbolleiste").Delete
End Sub
Viele Grüße,
Matthias