Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would like to have a custom menu with a drop down list. It would look
similar to the zoom % or font drop down list. I would like to initialize the list programmatically when the spreadsheet is opened. When the user selects a value from the list I would like to get control programatically to perform an action (via VBA) Is this possible? I've not been able to add a combobox to a menu from the toolbox. Regards, Leif |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is an example
With Application.CommandBars("Standard") With .Controls.Add(Type:=msoControlDropdown, temporary:=True) .Caption = "myDD" .AddItem "Bob" .AddItem "Lynne" .AddItem "Amy" .AddItem "Hannah" .OnAction = "myDDMacro" End With End With -- HTH RP (remove nothere from the email address if mailing direct) "Leif" wrote in message ... I would like to have a custom menu with a drop down list. It would look similar to the zoom % or font drop down list. I would like to initialize the list programmatically when the spreadsheet is opened. When the user selects a value from the list I would like to get control programatically to perform an action (via VBA) Is this possible? I've not been able to add a combobox to a menu from the toolbox. Regards, Leif |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob,
Thanks very much! Is there an event (like a form load or open) that I can use to initialize the control when the spreadsheet is opened? Also, how do I reference the control value in VBA? Thanks. "Bob Phillips" wrote: Here is an example With Application.CommandBars("Standard") With .Controls.Add(Type:=msoControlDropdown, temporary:=True) .Caption = "myDD" .AddItem "Bob" .AddItem "Lynne" .AddItem "Amy" .AddItem "Hannah" .OnAction = "myDDMacro" End With End With -- HTH RP (remove nothere from the email address if mailing direct) "Leif" wrote in message ... I would like to have a custom menu with a drop down list. It would look similar to the zoom % or font drop down list. I would like to initialize the list programmatically when the spreadsheet is opened. When the user selects a value from the list I would like to get control programatically to perform an action (via VBA) Is this possible? I've not been able to add a combobox to a menu from the toolbox. Regards, Leif |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Leif,
I think this is what you want Private Sub Workbook_Open() End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH RP (remove nothere from the email address if mailing direct) "Leif" wrote in message ... Bob, Thanks very much! Is there an event (like a form load or open) that I can use to initialize the control when the spreadsheet is opened? Also, how do I reference the control value in VBA? Thanks. "Bob Phillips" wrote: Here is an example With Application.CommandBars("Standard") With .Controls.Add(Type:=msoControlDropdown, temporary:=True) .Caption = "myDD" .AddItem "Bob" .AddItem "Lynne" .AddItem "Amy" .AddItem "Hannah" .OnAction = "myDDMacro" End With End With -- HTH RP (remove nothere from the email address if mailing direct) "Leif" wrote in message ... I would like to have a custom menu with a drop down list. It would look similar to the zoom % or font drop down list. I would like to initialize the list programmatically when the spreadsheet is opened. When the user selects a value from the list I would like to get control programatically to perform an action (via VBA) Is this possible? I've not been able to add a combobox to a menu from the toolbox. Regards, Leif |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob,
Thanks for your reply. As for the second part of my question I was able to find that the text property (Application.CommandBars("Test").Controls(1).Text) returns the selected text. However, each time I start Excel I get another drop down list. I did use temporary, as you said. From what I've read once the container application, Excel, closes the control should be gone, but it is not. I'm up to five controls now. My codes is as follows: Private Sub Workbook_Open() With Application.CommandBars("Test") With .Controls.Add(Type:=msoControlDropdown, temporary:=True) .Caption = "myDD" .AddItem "Bob" .AddItem "Lynne" .AddItem "Amy" .AddItem "Hannah" .OnAction = "myDDMacro" End With End With End Sub Regards, Leif "Bob Phillips" wrote: Hi Leif, I think this is what you want Private Sub Workbook_Open() End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH RP (remove nothere from the email address if mailing direct) "Leif" wrote in message ... Bob, Thanks very much! Is there an event (like a form load or open) that I can use to initialize the control when the spreadsheet is opened? Also, how do I reference the control value in VBA? Thanks. "Bob Phillips" wrote: Here is an example With Application.CommandBars("Standard") With .Controls.Add(Type:=msoControlDropdown, temporary:=True) .Caption = "myDD" .AddItem "Bob" .AddItem "Lynne" .AddItem "Amy" .AddItem "Hannah" .OnAction = "myDDMacro" End With End With -- HTH RP (remove nothere from the email address if mailing direct) "Leif" wrote in message ... I would like to have a custom menu with a drop down list. It would look similar to the zoom % or font drop down list. I would like to initialize the list programmatically when the spreadsheet is opened. When the user selects a value from the list I would like to get control programatically to perform an action (via VBA) Is this possible? I've not been able to add a combobox to a menu from the toolbox. Regards, Leif |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Always best to be doubly sure Leif
Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.CommandBars("Test").Controls("myDD").D elete On Error GoTo 0 End Sub Private Sub Workbook_Open() On Error Resume Next 'just in case Application.CommandBars("Test").Controls("myDD").D elete On Error GoTo 0 With Application.CommandBars("Test") With .Controls.Add(Type:=msoControlDropdown, temporary:=True) .Caption = "myDD" .AddItem "Bob" .AddItem "Lynne" .AddItem "Amy" .AddItem "Hannah" .OnAction = "myDDMacro" End With End With End Sub You can also pick up the value a bit more directly Sub myDDMacro() MsgBox CommandBars.ActionControl.Control.Text End Sub -- HTH RP (remove nothere from the email address if mailing direct) "Leif" wrote in message ... Bob, Thanks for your reply. As for the second part of my question I was able to find that the text property (Application.CommandBars("Test").Controls(1).Text) returns the selected text. However, each time I start Excel I get another drop down list. I did use temporary, as you said. From what I've read once the container application, Excel, closes the control should be gone, but it is not. I'm up to five controls now. My codes is as follows: Private Sub Workbook_Open() With Application.CommandBars("Test") With .Controls.Add(Type:=msoControlDropdown, temporary:=True) .Caption = "myDD" .AddItem "Bob" .AddItem "Lynne" .AddItem "Amy" .AddItem "Hannah" .OnAction = "myDDMacro" End With End With End Sub Regards, Leif "Bob Phillips" wrote: Hi Leif, I think this is what you want Private Sub Workbook_Open() End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH RP (remove nothere from the email address if mailing direct) "Leif" wrote in message ... Bob, Thanks very much! Is there an event (like a form load or open) that I can use to initialize the control when the spreadsheet is opened? Also, how do I reference the control value in VBA? Thanks. "Bob Phillips" wrote: Here is an example With Application.CommandBars("Standard") With .Controls.Add(Type:=msoControlDropdown, temporary:=True) .Caption = "myDD" .AddItem "Bob" .AddItem "Lynne" .AddItem "Amy" .AddItem "Hannah" .OnAction = "myDDMacro" End With End With -- HTH RP (remove nothere from the email address if mailing direct) "Leif" wrote in message ... I would like to have a custom menu with a drop down list. It would look similar to the zoom % or font drop down list. I would like to initialize the list programmatically when the spreadsheet is opened. When the user selects a value from the list I would like to get control programatically to perform an action (via VBA) Is this possible? I've not been able to add a combobox to a menu from the toolbox. Regards, Leif |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
fill combobox depending on selection from another combobox | Excel Discussion (Misc queries) | |||
Macro that Finds the First Value in a range using a Combobox (drop down menu) | Excel Worksheet Functions | |||
ComboBox list reliant on the entry from a different ComboBox | Excel Programming | |||
Menu items added with menu item editor in older versions | Excel Discussion (Misc queries) | |||
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox | Excel Programming |