Cheers Greg
If I remove the code then would the "OnAction" code persist?
At the moment I am fooling the Template into thinking that it has been saved
after I add the combobox, which seems to work OK and provides the option of
ammending the list at a later date (For instance the colour names at the
moment haven't been approved by PR and might change)
> Dan,
>
[quoted text clipped - 35 lines]
> > > Seems to me that you would put the SetComboList()
> > > code in an Auto_New and Auto_Open routine in the template.
Greg Maxey - 27 Oct 2006 14:11 GMT
Dan,
No not as currently written because the variable cb is not set in the
SetColour procedures.
Consider this approach. Build your combobox using the BuildControl code
and save the template.
Dim cb As CommandBarComboBox
Sub BuildControl()
'Run once. Save the template and delete this routine
Set cb = CommandBars("Colour").Controls.Add(msoControlComboBox)
With cb
.Caption = "Color Selector"
.OnAction = "SetColour"
.Style = msoComboNormal
.Width = 150
.AddItem "Green"
.AddItem "Purple"
End With
End Sub
Now use this code to set the colours. Unstet the commented out code
and run it once to find the index number of the control you previously
built. I assumed it was "1", but if there are more than one control on
the command bar you will need to know which index number to use in the
.Contols(?) statement.
Private Sub SetColour()
'Dim cbc As CommandBarControl
'For Each cbc In CommandBars("Colour").Controls
' MsgBox cbc.Caption & " " & cbc.Index
'Next
Set cb = CommandBars("Colour").Controls(1)
Select Case cb.Text
Case "Green"
MsgBox "Green"
Case "Purple"
MsgBox "Purple"
End Select
End Sub
> Cheers Greg
>
[quoted text clipped - 44 lines]
> > > > Seems to me that you would put the SetComboList()
> > > > code in an Auto_New and Auto_Open routine in the template.