oleneazer
09-08-2004, 07:18 PM
Hello----------------------(I'am french so excuse my poor english:bawl )
I try to make a personal toolbar wich contains tow comboBox
one to display days of the current month and the other one to display months of the current year
Here the code that i put in a standard module call by Workbook_Open
Sub Testbar()
Dim objPopUp As CommandBarPopup
Dim objButton As CommandBarButton
Dim iMois, iJour As Integer
Dim cb As CommandBar
Dim graphBtn As CommandBarButton
Set cb = CommandBars.Add(Name:="test", Position:=msoBarTop)
cb.Visible = True
Set objPopUp = cb.Controls.Add(msoControlPopup)
objPopUp.Caption = "Total-Jour de: " & UCase(Format(DateSerial(1, Month(Date), 1), "mmmm"))
For iJour = 1 To Day(DateSerial(Year(Date), Month(Date) + 1, 0))
Set objButton = objPopUp.Controls.Add
With objButton
.Caption = Format(DateSerial(Year(Date), Month(Date), iJour), "dddd dd")
.OnAction = "macro1"
.Style = msoButtonCaption
End With
Next iJour
Set objPopUp = cb.Controls.Add(msoControlPopup)
objPopUp.Caption = "TOTAL Mensuel"
For iMois = 1 To 12
Set objButton = objPopUp.Controls.Add
With objButton
.Caption = Application.WorksheetFunction.Proper(Format(DateSerial(1, iMois, 1), "mmmm"))
.OnAction = "Macro2"
.Style = msoButtonCaption
.BeginGroup = True
End With
Next iJour
End sub
I want change the code to have a menu in the toolbar with twos submenus one for the day and one for the months. Somebody can help me?
I try to make a personal toolbar wich contains tow comboBox
one to display days of the current month and the other one to display months of the current year
Here the code that i put in a standard module call by Workbook_Open
Sub Testbar()
Dim objPopUp As CommandBarPopup
Dim objButton As CommandBarButton
Dim iMois, iJour As Integer
Dim cb As CommandBar
Dim graphBtn As CommandBarButton
Set cb = CommandBars.Add(Name:="test", Position:=msoBarTop)
cb.Visible = True
Set objPopUp = cb.Controls.Add(msoControlPopup)
objPopUp.Caption = "Total-Jour de: " & UCase(Format(DateSerial(1, Month(Date), 1), "mmmm"))
For iJour = 1 To Day(DateSerial(Year(Date), Month(Date) + 1, 0))
Set objButton = objPopUp.Controls.Add
With objButton
.Caption = Format(DateSerial(Year(Date), Month(Date), iJour), "dddd dd")
.OnAction = "macro1"
.Style = msoButtonCaption
End With
Next iJour
Set objPopUp = cb.Controls.Add(msoControlPopup)
objPopUp.Caption = "TOTAL Mensuel"
For iMois = 1 To 12
Set objButton = objPopUp.Controls.Add
With objButton
.Caption = Application.WorksheetFunction.Proper(Format(DateSerial(1, iMois, 1), "mmmm"))
.OnAction = "Macro2"
.Style = msoButtonCaption
.BeginGroup = True
End With
Next iJour
End sub
I want change the code to have a menu in the toolbar with twos submenus one for the day and one for the months. Somebody can help me?