Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This forum is not for asking questions about writing your own macros.

When setting up tabular databases, it may be useful to use Calc even if it is not necessarily a purpose.We naturally know the possibility offered by the menu "Data" / "Validity" which allows to limit certain choices.But in some fields it is sometimes necessary to enter SEVERAL values, separated by a separator, knowing that their number is variable. To make it as concise as possible, it is sometimes necessary to use references, the shortest possible.The example given here makes a list of materials in the "system" sheet with their references.The macro makes it possible to call a dialog box that reads all the items of the sheet to have them in a dialog box that allows multiple selection (with mouse and [Ctrl] or [Shift] keys).It can also be noted that the dialog box is able to read the references written in the call cell.I opted for a dash for separating references because it is very clear. But this is a choice that can be changed in the code (and it is possible to put a separator of several characters).The order of references does not matter and one can very well grasp the references "by the hand". But if we validate the dialog with the "OK" button, then it will be put back in the one of "system.B3:C21".

' Sélection of the right choices if the active cell contain knowing references. mySelections = split(thisComponent.currentSelection.String, mySeparator) For myLines = 0 To myLinesNb For myLines1 = 0 to ubound(mySelections) If myRefs(myLines) = mySelections(myLines1) Then myDialog.getControl("ListBox1").selectItemPos(myLines, true) Exit For End If Next myLines1 Next myLines