toolbar menu combo boxes

  • Thread starter Thread starter Michael S. Montoya
  • Start date Start date
M

Michael S. Montoya

I would like to have a "preferences" checkbox in a menubar. If not a
checkbox, then a Combobox would do. I have seen some code aluding to adding
comboboxes to a menubar, but I couldn't get it to work

Basically, depending on the value of the combobox or checkbox, I want a
report to either print or preview. There are some other "preferences" I
would like to use if this works.

Does anyone know how to create the toolbar?

Also, when created, how does one reference the value from a form?

Thanks in advance.
 
Hi,
Here's a snippet from help. It worked for me first time:

Dim newCombo As CommandBarControl
Set newCombo = CommandBars("test").Controls _
.Add(Type:=msoControlComboBox)
With newCombo
.AddItem "Q1"
.AddItem "Q2"
.AddItem "Q3"
.AddItem "Q4"
.Style = msoComboNormal
.OnAction = "ScrollToQuarter"
End With

Before I ran the code I created a toolbar called 'test'. You also have to set a reference to the Office object library.
The topic in Help is:
Adding and Modifying Toolbars
 
Awesome..it was the reference I was missing.

Now that I have the combobox, how do I reference the value in a form? (If
help combo = -1 then preview)



Dan Artuso said:
Hi,
Here's a snippet from help. It worked for me first time:

Dim newCombo As CommandBarControl
Set newCombo = CommandBars("test").Controls _
.Add(Type:=msoControlComboBox)
With newCombo
.AddItem "Q1"
.AddItem "Q2"
.AddItem "Q3"
.AddItem "Q4"
.Style = msoComboNormal
.OnAction = "ScrollToQuarter"
End With

Before I ran the code I created a toolbar called 'test'. You also have to
set a reference to the Office object library.
 
Hi,
You have to write a function that will be run when the user makes a selection.
In the sample code it callsa function called: ScrollToQuarter

So, write your own function and have it run that.

Here is how you reference the chosen value:

Dim cbo As CommandBarComboBox
Set cbo = CommandBars.ActionControl
MsgBox cbo.List(cbo.ListIndex)
Set cbo = Nothing
 
Back
Top