Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If the combo box is in a Dialog or Userform then you need to populate the list for the combobox in the macro that initialises the Dialog.

Simple example below expects the range to initialise the combo box list to be in a vertical column range of cells.

Sub StartDialog

    Dim oList As Object
    Dim n As Integer
    Dim i As Integer
    Dim oDialog As Variant
    Dim oData As Variant

    ' Code for initiating and showing the dialog    '   
    DialogLibraries.LoadLibrary("Standard")
    oDialog = CreateUnoDialog( DialogLibraries.Standard.ImportTextFormat )

    oList = oDialog.getControl("FormatList")

    oList.Text = "Select text input format from the list."

    ' Read the data list from cell range into a variant array '
    oData = ThisComponent.Sheets(0).getCellRangeByName("C7:C9").DataArray

    n = ubound(oData)

    For i = 0 to n
        oList.addItem(oData(i)(0) ,i)
    Next i

    oDialog.Execute()
End Sub