this is some code previously posted by Rob Bovey that illustrates creating a
floating commandbar with a dropdown combobox and the macro assigned to
selection of an item in that control:
Option Explicit
Private Const szBAR_NAME As String = "ComboDemo"
Sub AddCmdBarCombo()
Dim cbrBar As CommandBar
''' Note, the class name of both types of control is CommandBarComboBox
Dim ctlComboBox As CommandBarComboBox
Dim lCount As Long
On Error Resume Next
CommandBars(szBAR_NAME).Delete
On Error GoTo 0
Set cbrBar = CommandBars.Add(szBAR_NAME, msoBarFloating)
cbrBar.Visible = True
Set ctlComboBox = cbrBar.Controls.Add(msoControlComboBox)
ctlComboBox.OnAction = ThisWorkbook.Name & "!HandleCombo"
For lCount = 1 To 5
ctlComboBox.AddItem "Item " & lCount
Next lCount
ctlComboBox.ListIndex = 0
End Sub
Sub HandleCombo()
Dim ctlComboBox As CommandBarComboBox
Dim szItem As String
Set ctlComboBox = CommandBars.ActionControl
szItem = ctlComboBox.Text
''' This is required to overcome a screen refresh bug in Excel 97.
Application.ScreenUpdating = False
Application.ScreenUpdating = True
MsgBox "You chose " & szItem
End Sub
--
Regards,
Tom Ogivy
"Ooz" wrote in message
...
yes, that seems to be a solution for my problem but I do not know to put
any control of mine to a toolbar. Is is possible to place controls
otherthan predifined buttons for commands and macros on to tool bars.
It would be great to have a dropdown list like the one for font size
that changes A1 in Sheet1 on a tool bar which floats over all the
worksheets.
can any one explain the procedure if such thing is possible
------------------------------------------------
Message posted from http://www.ExcelTip.com/
-- View and post Excel related usenet messages directly from
http://www.ExcelTip.com/forum
-- Hundreds of free MS Excel tips, tricks and solutions at
http://www.ExcelTip.com/
------------------------------------------------