vbabasiclibreoffice-calclibreoffice-basicopenoffice-basic

Libreoffice Unable to fill ListBox because I could not declare the listbox righteously


I have a Listbox in my Calc Worksheet and I am trying to address it for filling it with data

    DialogLibraries.LoadLibrary("Standard")
    oDialog = CreateUnoDialog(DialogLibraries.Standard)

    listBoxGruppe = oEvent.Source.Context.getControl("Drop_Down_5") 'oDialog.getControl("Drop_Down_5")

    aItems = sheetb.getCellRangeByName(subStrRan).dataarray
    Dim sItems(ubound(aItems))
    For i = 0 To ubound(aItems)
        sItems(i) = aItems(i)(0)
     Next i
     
     listBoxGruppe.addItems(sItems, 0)

    oDialog.Execute()  

However, it seems u need to call a certain Dialog, but idk what is the name of my Dialog for this scenario - this is how my code behind looks like


Solution

  • I think you don't need dialogs at this situation

    dim RangeAddr as new com.sun.star.table.CellRangeAddress
        
        RangeAddr.EndColumn = 1
        RangeAddr.EndRow = Cell.CellAddress.Row
        RangeAddr.Sheet = 2
        RangeAddr.StartColumn = 1
        RangeAddr.StartRow = 0
        
        dim initParam(0) as new com.sun.star.beans.NamedValue
        initParam(0).Name="CellRange"
        initParam(0).Value = RangeAddr
        CellRangeListSource = doc.createInstanceWithArguments("com.sun.star.table.CellRangeListSource", initParam )
        listBoxGruppe.setListEntrySource CellRangeListSource