Adding a Dropdown Control to a Command Baar

T

Tom Joseph

I would like to replace one of the command buttons with a dropdown control.
I would like the dropdown control to have several list items, each of which
should have an onAction property.

Here is what I am starting with.

Any help and some example code woud be much appreciated.

Thanks,


Sub OpenCommandBar()

Dim cb As CommandBar
Dim cbb As CommandBarButton

Set cb = Application.CommandBars.Add("Dashboard Controls", _
msoBarFloating, False, True)
cb.Enabled = True
cb.Visible = True

Set cbb = cb.Controls.Add(msoControlButton)
cbb.Style = msoButtonIconAndCaption
cbb.Caption = "Refresh Data"
cbb.FaceId = 159
cbb.OnAction = "InitializeDataInput2"

Set cbb = cb.Controls.Add(msoControlButton)
cbb.Style = msoButtonIconAndCaption
cbb.Caption = "Generate Reports"
cbb.FaceId = 433
cbb.OnAction = "ProcessReportSet01"

Set cbb = cb.Controls.Add(msoControlButton)
cbb.Style = msoButtonIconAndCaption
cbb.Caption = "Print Reports"
cbb.FaceId = 4
cbb.OnAction = "PrintSet01"

Set cbb = cb.Controls.Add(msoControlButton)
cbb.Style = msoButtonIconAndCaption
cbb.Caption = "eMail Reports"
cbb.FaceId = 258
cbb.OnAction = "CreateAndEmailReports"

End Sub
 
J

Jim Cone

You omitted the "control"...
'--
Sub OpenCommandBar()
Dim cb As CommandBar
Dim cbb As CommandBarButton
Dim cbc As CommandBarControl

Set cb = Application.CommandBars.Add("Dashboard Controls", _
msoBarFloating, False, True)
cb.Enabled = True
cb.Visible = True

Set cbc = cb.Controls.Add(msoControlPopup)
cbc.Caption = "Refresh Data"
cbc.OnAction = "InitializeDataInput2"
'cbc.FaceId = 159
'cbc.Style = msoButtonIconAndCaption

Set cbb = cbc.Controls.Add(msoControlButton)
cbb.Style = msoButtonIconAndCaption
cbb.Caption = "Generate Reports"
cbb.FaceId = 433
cbb.OnAction = "ProcessReportSet01"

Set cbb = cbc.Controls.Add(msoControlButton)
cbb.Style = msoButtonIconAndCaption
cbb.Caption = "Print Reports"
cbb.FaceId = 4
cbb.OnAction = "PrintSet01"

Set cbb = cbc.Controls.Add(msoControlButton)
cbb.Style = msoButtonIconAndCaption
cbb.Caption = "eMail Reports"
cbb.FaceId = 258
cbb.OnAction = "CreateAndEmailReports"
End Sub
--
Jim Cone
Portland, Oregon USA


"Tom Joseph"
<[email protected]>
wrote in message
I would like to replace one of the command buttons with a dropdown control. I would like the dropdown control to have several list
items, each of which
should have an onAction property.
Here is what I am starting with.
Any help and some example code woud be much appreciated.
Thanks,


Sub OpenCommandBar()
Dim cb As CommandBar
Dim cbb As CommandBarButton

Set cb = Application.CommandBars.Add("Dashboard Controls", _
msoBarFloating, False, True)
cb.Enabled = True
cb.Visible = True

Set cbb = cb.Controls.Add(msoControlButton)
cbb.Style = msoButtonIconAndCaption
cbb.Caption = "Refresh Data"
cbb.FaceId = 159
cbb.OnAction = "InitializeDataInput2"

Set cbb = cb.Controls.Add(msoControlButton)
cbb.Style = msoButtonIconAndCaption
cbb.Caption = "Generate Reports"
cbb.FaceId = 433
cbb.OnAction = "ProcessReportSet01"

Set cbb = cb.Controls.Add(msoControlButton)
cbb.Style = msoButtonIconAndCaption
cbb.Caption = "Print Reports"
cbb.FaceId = 4
cbb.OnAction = "PrintSet01"

Set cbb = cb.Controls.Add(msoControlButton)
cbb.Style = msoButtonIconAndCaption
cbb.Caption = "eMail Reports"
cbb.FaceId = 258
cbb.OnAction = "CreateAndEmailReports"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top