PC Review


Reply
Thread Tools Rate Thread

Button controlled "self populating PopUP" menu

 
 
Tom-n-Nash
Guest
Posts: n/a
 
      4th Oct 2009
My project has 3 buttons on the User page that "pop up" a menu (shortcut
type) when clicked. On one of the menus, I need the sub-options for a primary
option to be generated when the button is clicked. In other words, it should
pull information from a range of cells on another page. This range varies
depending on previous information gathered through the use of userforms. I
have seen menus that do this, and have seen a similar example in a book, but
can't figure out how to modify the code for a popup menu. How can I include
code in my menu creation code that allows something like: for each c in
sheets??range(XY)... .AddItem.c then use this with List(ListIndex) to make a
menu use that info to make a list of sub-options?
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      4th Oct 2009
If you mean the popup menu; try the below

On the active sheet Range("A1:A10") type some values say 1 to 10 and run the
below macro..

Sub Macro()
Dim cell As Range
Dim cbCTLPop As CommandBarPopup, cbCTLBut As CommandBarButton

On Error Resume Next
Application.CommandBars("MyBar").Delete
Application.CommandBars.Add "MyBar", Position:=msoBarPopup, _
Temporary:=True

Set cbCTLPop = Application.CommandBars("MyBar").Controls.Add( _
Type:=msoControlPopup, Temporary:=True)
cbCTLPop.Caption = "My menu"

For Each cell In Range("A1:A10")
Set cbCTLBut = cbCTLPop.Controls.Add(Temporary:=True)
With cbCTLBut
.Caption = cell.Text
.Style = msoButtonCaption
.OnAction = "Macro_" & cell.Text
End With
Set cbCTLBut = Nothing
Next
Application.CommandBars("MyBar").ShowPopup
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Tom-n-Nash" wrote:

> My project has 3 buttons on the User page that "pop up" a menu (shortcut
> type) when clicked. On one of the menus, I need the sub-options for a primary
> option to be generated when the button is clicked. In other words, it should
> pull information from a range of cells on another page. This range varies
> depending on previous information gathered through the use of userforms. I
> have seen menus that do this, and have seen a similar example in a book, but
> can't figure out how to modify the code for a popup menu. How can I include
> code in my menu creation code that allows something like: for each c in
> sheets??range(XY)... .AddItem.c then use this with List(ListIndex) to make a
> menu use that info to make a list of sub-options?

 
Reply With Quote
 
Tom-n-Nash
Guest
Posts: n/a
 
      4th Oct 2009
Thank you so much Jacob.. I've been trying for days to come up with this!
It's exactly what I need. You Terrific! Tom

"Jacob Skaria" wrote:

> If you mean the popup menu; try the below
>
> On the active sheet Range("A1:A10") type some values say 1 to 10 and run the
> below macro..
>
> Sub Macro()
> Dim cell As Range
> Dim cbCTLPop As CommandBarPopup, cbCTLBut As CommandBarButton
>
> On Error Resume Next
> Application.CommandBars("MyBar").Delete
> Application.CommandBars.Add "MyBar", Position:=msoBarPopup, _
> Temporary:=True
>
> Set cbCTLPop = Application.CommandBars("MyBar").Controls.Add( _
> Type:=msoControlPopup, Temporary:=True)
> cbCTLPop.Caption = "My menu"
>
> For Each cell In Range("A1:A10")
> Set cbCTLBut = cbCTLPop.Controls.Add(Temporary:=True)
> With cbCTLBut
> .Caption = cell.Text
> .Style = msoButtonCaption
> .OnAction = "Macro_" & cell.Text
> End With
> Set cbCTLBut = Nothing
> Next
> Application.CommandBars("MyBar").ShowPopup
> End Sub
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Tom-n-Nash" wrote:
>
> > My project has 3 buttons on the User page that "pop up" a menu (shortcut
> > type) when clicked. On one of the menus, I need the sub-options for a primary
> > option to be generated when the button is clicked. In other words, it should
> > pull information from a range of cells on another page. This range varies
> > depending on previous information gathered through the use of userforms. I
> > have seen menus that do this, and have seen a similar example in a book, but
> > can't figure out how to modify the code for a popup menu. How can I include
> > code in my menu creation code that allows something like: for each c in
> > sheets??range(XY)... .AddItem.c then use this with List(ListIndex) to make a
> > menu use that info to make a list of sub-options?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Files in "Attach File" popup menu no longer alphabetical Mark L Microsoft Outlook Discussion 2 21st Jan 2010 08:40 PM
How To Trim Popup List for "Menu Background" Options in Nero 6? Martin Windows XP MovieMaker 6 7th Jun 2008 08:14 AM
"News" button missing from the "Go" menu & from the "add button" l =?Utf-8?B?cmdvcmRvbg==?= Microsoft Outlook Discussion 1 23rd Mar 2006 10:17 AM
What does the "Paste Special Dropdown" popup menu do? R Avery Microsoft Excel Programming 2 15th Dec 2004 02:28 PM
Sample code to add menu item to default "RIght-Click" popup menu *no spam* Microsoft Access Form Coding 0 26th Feb 2004 05:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:33 PM.