Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default combobox in a menu

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default combobox in a menu

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default combobox in a menu

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default combobox in a menu

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default combobox in a menu

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default combobox in a menu

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
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
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
Macro that Finds the First Value in a range using a Combobox (drop down menu) [email protected] Excel Worksheet Functions 2 July 12th 07 07:50 PM
ComboBox list reliant on the entry from a different ComboBox ndm berry[_2_] Excel Programming 4 October 4th 05 04:40 PM
Menu items added with menu item editor in older versions Michael Hoffmann Excel Discussion (Misc queries) 2 January 7th 05 01:40 PM
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox Minitman[_4_] Excel Programming 3 October 26th 04 07:58 PM


All times are GMT +1. The time now is 01:04 AM.

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

About Us

"It's about Microsoft Excel"