LibreOffice Calc - How to pass a Button form control 'Additional Info' data or URL data into a macro?

53 views Asked by At

There are suggestions that a form control Push Button can pass data into the macro it calls on execution via the "Additional Info" option (in Control Properties) or the URL option. How can this be achieved? It would be incredibly useful to do this. E.g. press a button with the "Additional Info" field containing the string "Apples" and it writes it into Cell A1. I should add, I am unable to get any code relating to the possibility of doing this to work.

1

There are 1 answers

0
Micklos On
Sub UseMyTag(pEvent)
ButtonParameters = pEvent.Source.Model
data = ButtonParameters.Tag
msgbox(data) 'returns ".jose"
End Sub

in the "Additional information..." field, within the Control Properties of the button, type a period '.' then the start of the string, e.g. .jose You can parse "data" to grab elements of the string you desire.

Source:https://ask.libreoffice.org/t/how-do-i-change-a-push-button-label-from-macro/53982 (Tq to JohnSUN and Lupp)

UPDATE: It seems the period in front of the string isn't actually necessary. Try not using it. If you get problems then put it back.