CommandBar Popup

P

Patrick386

Hello!

I have created a dropdown menu (msoControlPopup control) attached to a commandbar.
The thing is this dropdown menu is composed of buttons created dynamically depending on a list selected from a table.
so I can have 0, 2 or 100 buttons depending on the items found on the table.

my problem deals with the property OnAction of the buttons.

because they must have different actions, I cannot give them all a different procedure name, because I'll need to set procedure1, procedure2... 100
or to set one procedure with a received parameter.

but OnAction does not let a place for any parameter.. only the procedure name

so how can I know which button was clicked if I cannot make a different procedure (because of the dynamic number of buttons)?

Thanks in advance!
 
A

Albert D. Kallal

Actually, you can use parameters, you just have to "form" the string in
code.

eg:


=Myfunction("menu1")

The above is a legitimate "on action" function, and the public function
"myFunction" would received the above one parameter

eg:

Public Funciton MyFunction(strMenuOpt as string)

msgbox "menu option is = " & strMenuOpt

(the above would show "menu option is = menu1")

in code, thus, you set the above string as:

strAction = "=MyFunction(" & chr(34) & "Menu1" & chr(34) & ")"

commandBar("whatever").OnAction = strAction.

So, you can both set the actual function that the menubar calls, and you can
pass parameters as above...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top