Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
GUS GUS is offline
external usenet poster
 
Posts: 45
Default add combo box at popup menu

How can i add a combobox with 10 rows in the popup menu (rightclick menu)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default add combo box at popup menu

Watch for linewrap. This should get you started. I left in some
options (commented out) that you can try. Not sure what your goal is.

Search Google Groups for msocontrolcombobox Excel for more ideas.

----------------------------------------------------------------------------------------------------------

Sub AddComboBox()
'' Places the ComboBox on the shortcut menu.

Dim cbCBO As CommandBarComboBox
Dim intI As Integer
Dim rngFill As Range
Dim varFill As Variant

' Set rngFill = Range("A1:A10") ' Use this for list of names in a
range.
' varFill = rngFill.Value

varFill = Array("First", "Second", "Third", "Fourth", "Fifth", _
"Sixth", "Seventh", "Eighth", "Ninth", "Tenth")

Set cbCBO =
CommandBars("Cell").Controls.Add(Type:=msoControlC omboBox)

With cbCBO
.Caption = "Please Select"

For intI = LBound(varFill) To UBound(varFill)
.AddItem varFill(intI)
' .AddItem varFill(intI, 1)
Next intI

.Style = msoComboNormal
.OnAction = "Hello"
.Tag = "__This Combo__"
End With

End Sub

Sub DeleteComboBox()
' Deletes the combobox.

CommandBars("Cell").FindControl(Tag:="__This Combo__").Delete

End Sub

Sub Hello()
' Displays a MsgBox of nacros to run.

Dim cbCBO As CommandBarComboBox
Dim intIndex As Integer
Dim strIndex As String

' Set cbCBO = CommandBars("Cell").FindControl(Tag:="__This
Combo__")

intIndex = CommandBars("Cell").FindControl(Tag:="__This
Combo__").ListIndex

' Select Case cbCBO.List(cbCBO.ListIndex) ' This is a string. So
Case "First, Case "Second"

Select Case intIndex
Case 1: strIndex = "FirstMacro"
Case 2: strIndex = "SecondMacro"
Case 3: strIndex = "ThirdMacro"
Case 4: strIndex = "FourthMacro"
Case 5: strIndex = "FifthMacro"
Case 6: strIndex = "SixthMacro"
Case 7: strIndex = "SeventhMacro"
Case 8: strIndex = "EighthMacro"
Case 9: strIndex = "NinthMacro"
Case 10: strIndex = "TenthMacro"
Case Else:
End Select

MsgBox "You are about to run the " & strIndex & "."

CommandBars("Cell").FindControl(Tag:="__This Combo__").ListIndex = 0

End Sub

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------
On Wed, 24 Sep 2003 21:47:40 +0300, "GUS" wrote:

How can i add a combobox with 10 rows in the popup menu (rightclick menu)


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Popup Menu / Shortcut Menu Dale Fye Excel Discussion (Misc queries) 2 October 12th 07 12:57 AM
Combo in Menu bar bobby Excel Discussion (Misc queries) 0 January 11th 06 06:40 PM
create dropdown menu using Combo box Anthony Excel Worksheet Functions 1 January 29th 05 06:15 PM
Non-functional Popup Menu Boxes Jim_M Charts and Charting in Excel 0 January 20th 05 04:27 PM
Modifying the right-click popup menu of a shape Don Lopez Excel Programming 2 July 23rd 03 10:03 PM


All times are GMT +1. The time now is 06:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"