View Full Version : Pulldown Toolbar
GeekPatrol
03-02-2006, 04:11 PM
I am interested in making a pull down list similar to the Fonts or Styles pull down list and putting it into a custom toolbar.
I would be very pleased if someone has an example that simply creates a pull down list with 5 items which would be the numbers 1 through 5 and when an item is selected that a messagebox is displayed with the same cooresponding number as the list item.
My disconnect is creating the toolbar item as a pull down object. Where have I missed the boat?
Thank You,
-greg
TonyJollans
03-03-2006, 05:53 AM
Hi GeekPatrol,
Welcome to VBAX!
Unfortunately I think the amswer to your first question here has to be: no, it can't be done. Dropdowns are one of a few types of toolbar controls that Microsoft have seen fit to keep for themselves.
Killian
03-03-2006, 06:10 AM
Yes, it is a shame about not having access to certain objects.
I suppose the closest you'll get is a standard popup controlSub BuidToolbar()
Dim cb As CommandBar
Dim ctrlPop As CommandBarPopup
Dim ctrl As CommandBarButton
Dim i As Long
Set cb = CommandBars.Add("TEMPBAR", msoBarFloating)
cb.Visible = True
Set ctrlPop = cb.Controls.Add(msoControlPopup)
With ctrlPop
.Caption = "Select..."
For i = 1 To 5
Set ctrl = .Controls.Add(msoControlButton)
With ctrl
.Caption = "Button " & i
.Tag = i
.OnAction = "ShowMessage"
End With
Next i
End With
End Sub
Sub ShowMessage()
MsgBox "The properties of the clicked control are available" & vbLf & _
"This is the tag value we set: " & CommandBars.ActionControl.Tag
End Sub
Sub DeleteToolBar()
Dim cb As CommandBar
Dim ctrlPop As CommandBarPopup
Dim ctrl As CommandBarButton
For Each cb In CommandBars
If cb.Name = "TEMPBAR" Then cb.Delete
Next
End Sub
GeekPatrol
03-04-2006, 06:23 AM
Never say never is my favorite state of mind...
I got an answer from another site which I will share here.
http://www.experts-exchange.com/Applications/MS_Office/Word/Q_21758772.html
TonyJollans
03-04-2006, 07:12 AM
Well, there you go - wrong again :)
It's funny but you get an idea in your head and after a while you don't question it until somebody else points out the mistake. Thank you, Greg.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.