Macro to access getSelectItem() in a listbox in calc

After using 3 days of search with no luck…

I just want to build a macro that uses select item in a listbox.

Some friendly soal that can show a small example (perhaps just a single print) of the select item from a listbox ?

Aaah finaly …

To list its position in the listbox

oForm = ThisComponent.getSheets.getByName("your sheet").getDrawPage().getForms().getByIndex(0)
oListBox = oForm.getByName("ListBox")
items = oListBox.selectedItems
Print items(0)

To list the actual value

oForm = ThisComponent.getSheets.getByName("your sheet").getDrawPage().getForms().getByIndex(0)
oListBox = oForm.getByName("ListBox")
item = oListBox.CurrentValue
Print item

If you now what sheet you can user its ordernrumber like ThisComponent.Sheets(0)

Yes, you’re right, this is how it is done from a macro. By the way, most actions with ListBox do not require a macro - all actions can be performed only with formulas and control properties. Here’s an example - ListBox_Demo.ods