So.., I'm saying use a single entry point menuitem to execute a
It does, but it's not where I'm headed.
http://tinyurl.com/66ah47u
In the picture of the menu the URL directs you to, if, say...Elmer
Fudd was to set the value of ActNum to 2, then run the macro, the
macro would then populate a base page with data.
That's where I'm headed.
So, in effect, the menuitem would need to perform two functions when
clicked...set the variable, and then call the procedure.
Is that possible?
I saw where you're headed; -not recommending you continue that path!
Menuitems have 2 properties you can store values in: 'Tag' and
'Parameter'. Both these store string values by default, so any numeric
values will have to be converted with a function like CLng(), for
example. Excel will know which menuitem was selected.
So.., in your procedure you need to get the property value stored and
then run with it...
<Control>.OnAction = "MyProcess"
Sub MyProcess()
Dim myValue As String, myNum As Long
myValue = CommandBars.ActionControl.Tag
'or...
myNum = CLng(CommandBars.ActionControl.Tag)
'Do stuff based on myValue or myNum
End Sub
===
Optionally...
Choice1:
You could implement a VB[A] function named "CallByName" whereby you can
run a method and pass any args you want, but this would require putting
the procs inside a class so they are Public methods of the class. IMO,
this is way too complicated for what you're trying to do.
Given what you explained so far, I would use a single menuitem and let
the entry point procedure (or VBA) decide what to do.
Choice2:
Have a single menuitem display a userform with a ListBox that users can
scroll to select actions. Use the list item's Index property to
identify which item was clicked, and pass a parameter based on that.
The names can be read into the list from a worksheet, and any other
values you want to use can be put into additional columns of the
ListBox. (not all cols need be visible if all you want to show is a
list of names)