In addition to what @EasyTrieve said:
When writing a macro for handling a FormControl event you need to provide a formal paramtere for the event. When called due to an action on the button this parameter gets an object assigned that contains all the needed information. Its indirect property .Source.Model
gives access to the control (a PushButton in your case) having raised the event. There you also find the .Label
string.
Additional advice: The .Label
property is what you see displayed on the Button. It may not be the bset place to pass additional information. The object inspector working on any control also has a line titled ‘Additional information’ under the tab General
which is more appropriate for the purpose. However you need to know that the model’s property giving access to that information (string) is .Tag
in the API.
===Edit1 2019-02-06 23:08 (UTC+1:00)===
I did a bit more meanwhile because I got interested in the question requiring probably an approach from a somehow theoretical starting point.
For programmers of user code it is a well known annoying problem to pass parameters to subroutines needing to be called via >Tools>Macros>Run or by an event raised by MouseClick on a sensitive area. Using Calc I prefer cell ranges for the purpose. Working with text douments TextTable can be a (uncomfortable) surrogate.
It’s different and much more complicated if there shall be used “many” FormControl, most Likely of PushButton type. To a first view it seems unavoidable to edit every single button pasing information to the Sub to call via the .Tag (or .Label ??) property e.g.
I wanted to find a way to simply create one such button associated with one Sub (that will have to select cases internally), to copy this button and paste it into (e.g) the cells of a table column, and to take the needed additional information after the event raising action from an adjacent column then.
It was a bit challenging, and it isn’t satisfyingly efficient. I nonetheless attach this example demonstrating how to do it in prínciple. The included Sub for the disambiguation of control names may be of some interest independent of this special question.
Of course I am interested in solutions proving my attempt unnecessarily complicated.