Hi all. I’m trying to sort a table in a document via a macro. I can find the table of interest and also select the whole table ready for sorting, but a command I found that is supposed to work isn’t doing anything - sortTextTable. Using the menu to sort works fine.
sortAscend = True 'asc sorting
headerPresent = True 'table contains a header row
sortingCol = 1 ''column number to sort on
tableList = ThisComponent.getTextTables() 
For indexNum = 0 To tableList.getCount() - 1
    tableItem = tableList(indexNum) 'Get the individual table object
    tableName = tableItem.getName() 'get the table name
    If tableName = "Table1" Then
        tableViewCursor = ThisComponent.CurrentController.getViewCursor()
        ThisComponent.CurrentController.select(tableItem)
        tableViewCursor.gotoEnd(True) 'Move to the end of the current cell.
        tableViewCursor.gotoEnd(True) 'Move to the end of the table.
        tableItem.sortTextTable(tableName, sortAscend, headerPresent, sortingCol)
    End If
Next
Any help is appreciated
Version: 25.2.3.2, Windows 10
      
    
