Dropdownliste in Symbolleiste

25.01.2002


Anstelle vieler Symbole in einer Symbolleiste kann man sich helfen,
wenn man beispielsweise zusammenhängende Routinen
in eine Dropdownliste setzt:

 



Const CBName = "Meine Makros"
Sub Symbolleiste_erstellen()
    Call Symbolleiste_löschen
    CommandBars.Add Name:=CBName  
    With CommandBars(CBName)
        .Position = msoBarTop
        .Visible = True
        .Controls.Add Type:=msoControlDropdown
    End With
    With CommandBars(CBName).Controls(1)
        .Caption = CBName
        .AddItem "Routine 1"
        .AddItem "Routine 2"
        .AddItem "Routine 3"
        .ListIndex = 1
        .OnAction = "MachWas"
        .TooltipText = "Meine Routinen..."
    End With
End Sub
Sub Symbolleiste_löschen()
    On Error Resume Next
    CommandBars(CBName).Delete
End Sub
Sub MachWas()
    Dim objList As CommandBarControl
    Dim Auswahl As Byte
    Set objList = CommandBars.ActionControl
    Auswahl = objList.ListIndex
    Select Case Auswahl
        Case 1:
            MsgBox "Routine 1", vbExclamation
        Case 2:
            MsgBox "Routine 2", vbExclamation
        Case 3:
            MsgBox "Routine 3", vbExclamation
    End Select
End Sub