Gruppe
Menue
Problem
Wie kann ich eine Symbolleiste mit einer CommandBarComboBox hinzufügen und dieser als Startwert das aktuelle Datum zuordnen? Der Symbolleiste soll eine weitere Schaltfläche hinzugefügt werden, die auf Mausklick das Datum in der CommandBarComboBox um 1 erhöht.
ClassModule: DieseArbeitsmappe
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call Loeschen
End Sub
StandardModule: basMain
Sub DatumInControl()
Dim oBar As CommandBar
Dim oCbo As CommandBarComboBox
Dim oBtn As CommandBarButton
Set oBar = CommandBars.Add( _
Name:="MeineSymbolleiste", _
Position:=msoBarTop, _
MenuBar:=False, _
temporary:=True)
oBar.Visible = True
Set oCbo = oBar.Controls.Add(Type:=msoControlComboBox)
With oCbo
.Caption = "Datum"
.AddItem Date
End With
Set oBtn = oBar.Controls.Add
With oBtn
.FaceId = 36
.OnAction = "Erhoehen"
oCbo.ListIndex = 1
End With
End Sub
Sub Erhoehen()
With Application.CommandBars("MeineSymbolleiste").Controls("Datum")
.List(1) = Format(DateValue(.List(1)) + 1, "dd.mm.yy")
End With
End Sub
Sub Loeschen()
On Error GoTo ERRORHANDLER
Application.CommandBars("MeineSymbolleiste").Delete
ERRORHANDLER:
End Sub