ho la necessità di impostare i parametri di una listbox mediante una macro.
Spulciando nei forum ho recuperato dei "pezzi" di codice che "composti" ottengono quasi il risultato desiderato.
In particolare il codice allegato è in grado di impostare correttamente il valore della "Cella collegata" e di "Area celle di origine".
A me servirebbe che il campo "Contenuti della cella collegata" fosse impostato a "Posizione della voce selezionata" in realtà viene impostato a "La voce selezionata"
Ho provato ad ispezionare gli oggetti con MRI e Xray nel tentativo di identificare un metodo/proprietà che consentisse di impostare il parametro sopradescritto come richiesto ma senza successo.
Grazie per l'aiuto.
Codice: Seleziona tutto
Sub FindControl
Dim oSheet
Dim oForm
Dim oControlDataModel
Dim oControl
Dim oService
Dim arg(0) as new com.sun.star.beans.NamedValue 'not a PropertyValue, a Named Value.
Dim oCellAddress As new com.sun.star.table.CellAddress
Dim addr As Object
Dim oCellRangeListSource
Dim initParam(0) as new com.sun.star.beans.NamedValue
Globalscope.BasicLibraries.LoadLibrary("MRILib")
' oMRI = CreateUnoService("mytools.Mri")
addr = createUnoStruct("com.sun.star.table.CellRangeAddress")
addr.StartRow=0
addr.EndRow=12
addr.StartColumn=13
addr.EndColumn=13
addr.Sheet=0
initParam(0).Name="CellRange"
initParam(0).value = addr
oCellRangeListSource=ThisComponent.createInstanceWithArguments("com.sun.star.table.CellRangeListSource", initParam() )
oForm = ThisComponent.DrawPages(0).Forms(0).getByIndex(0)
oForm.setListEntrySource(oCellRangeListSource)
oSheet = ThisComponent.CurrentController.ActiveSheet
' Assume there is only one form.
oForm = oSheet.getDrawPage().getForms().getByIndex(0)
oControlDataModel = oForm.getByName(oForm.ElementNames(0))
oCellAddress.Column =15
oCellAddress.Row=0
oCellAddress.Sheet=0
arg(0).Name = "BoundCell"
arg(0).Value = oCellAddress
oService = ThisComponent.createInstanceWithArguments("com.sun.star.table.CellValueBinding", arg)
' oMRI.inspect(oService)
oControlDataModel.ValueBinding = oService
End Sub