LibreOffice Basic - Getting all items listed in a ComboBox

Ladies and Gents,

I am having the most difficult time attempting to find any explanation on how I can access each item within a ComboBox.

I have created my own custom form (named “NewTransaction”) using LibreOffice Basic (v5.0.3.2). On it, I have a combobox named “cmbxCategory”. In my code module, I have the following code:

Function ShowDialog_NewTransaction
Dim dialogBox_NewTrans As Object

Set dialogBox_NewTrans = LoadDialog("Standard", "NewTransaction")

With dialogBox_NewTrans
	With .GetControl("cmbxCategory")
		.addItem("Food", 0)
		.addITem("Drinks", 1)
		MsgBox .ListEntries(0)
	End With
End With

End Function

What I am ultimately after is to be able to call, at any time, the nth item in a combobox and store it into a string. Perhaps, I will want to assign “text” to be equal to the first item in the list. I understand that I may go out of bounds. Obviously, I receive an error on the MsgBox .ListEntries(0) line.

How can I set the chosen text to be equal to the nth item in the combobox list? How can I determine the number of elements in the combobox list so that I can prevent going out of bounds?

Also, I am considered an Expert at my job with regard to MS VBA, but for LibreOffice, I can’t seem to find any good documentation showing all available method calls, in this case, for a combobox. What would you recommend I reference when it comes to looking for various method calls?

Thank you for all your help!


In order to better answer your question I have attached a sample. Your question states you created a form, but the code appears to be dealing with a dialog. The sample uses a form with a button. Pressing the button will execute the macro to generate a dialog. Before the dialog appears, there will be message boxes depicting some information within the two controls appearing on the dialog. One control is a list box and the other is a combo box.

As far as documentation, it is scattered all over the place. There is no one location. However, this post provides a variety of links you might be interested in. Two specific items are the LO documentation and OOME by Andrew Pitonyak both within the list.

One place to look for all method calls is a tall order. A more common starting point is to learn to use an Object Inspector such as MRI or XRay again both on the list.

Sample: ListVsCombo.odb

My apologies…I created a dialog, from the dialog editor. In MS VBA the dialogs are known as Userforms. I am not at home yet and thus have not yet opened your example, but I will this evening.


In MS VBA, I am able to pull up a listing of available method calls after a command. For example, when I type:

Shift.Cells(3, 4).

I will get a drop down menu (or, I may have to press Ctrl+Spacebar) that shows me many things, including “value”, which I am ultimately interested in.

In LO Basic, is there such an option or plug-in for that in LO?? Perhaps that is what MRI and XRay do??

Many thanks for the feedback. I’ll get back to you this evening.


There is no help (built-in or plug-in) in LO for values as you mention. The object inspectors do this in a way but is actually viewed in another window. This reveals settings available and can link to documents which state the values and methods allowed.

Also, since you have Access background, on the post provided in my answer is a link to Access2Base. This may ease the transition but will add overhead. When I first started with base I chose to bypass this and just learn the LO API.

Well, hot dogs. The code in your file works. The line I was needing in place of the MsgBox is:

.Text = .GetItem(n)

To ensure that I don’t go out of bounds, I will also incorporate:


Thank you VERY much for your time!!!

If this answers your question please click on the :heavy_check_mark: (upper left area of answer).