I’m translating a series of VB6 packages to work with LO Calc instead of MS Excel and am doing fine except for sorting. The following code raises no errors but doesn’t work and I can’t see why. It works fine as a macro.
Sub SortRangeF()
Dim loSheet ' loCalc sheet containing data to sort.
Dim loCellRange ' Data range to sort.
Dim loSortFields(0)
Dim loSortDesc(1)
loSheet = loCalc.sheets.getByName("Sheet1")
loCellRange = loSheet.getCellRangeByName("B1:D50")
loCalc.getCurrentController.Select loCellRange 'Only to highlight the range.
loSortFields(0) = MakeSortField(2, True) 'Sort on column C ascending.
loSortDesc(0) = MakePropertyValue("SortFields", loSortFields())
loSortDesc(1) = MakePropertyValue("ByRows", True)
loCellRange.sort (loSortDesc())
'CallByName loCellRange, "Sort", VbMethod, loSortDesc()
End Sub
MakeSortField and MakePropertyValue are functions which work in other contexts. loCalc is the workbook object. I’ve also tried using CallByName with the same result: no errors, no sort.
OS Windows7 Prof. LO 6.3.6.2