Running a sort in libreoffice 5.3.4.2 (x64) on windows 10 allows you to make a large number of sort criteria. If you attempt to record a macro of a sort with more than 3 criteria, the macro only records the first 3 and ignores the rest, although the initial sort that is done works fine.
Attempting to manually add more sort criteria into the macro results in a macro that still only sorts the first 3 criteria in the list, although it does technically have more sort criteria in it.
Is this a bug or is there some other way to sort more than 3 criteria with a macro?
Recorded macro from a 5 column sort:
sub SortColumnB
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$B$5:$F$14"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(12) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ByRows"
args2(0).Value = true
args2(1).Name = "HasHeader"
args2(1).Value = false
args2(2).Name = "CaseSensitive"
args2(2).Value = false
args2(3).Name = "NaturalSort"
args2(3).Value = false
args2(4).Name = "IncludeAttribs"
args2(4).Value = true
args2(5).Name = "UserDefIndex"
args2(5).Value = 0
args2(6).Name = "Col1"
args2(6).Value = 2
args2(7).Name = "Ascending1"
args2(7).Value = true
args2(8).Name = "Col2"
args2(8).Value = 3
args2(9).Name = "Ascending2"
args2(9).Value = true
args2(10).Name = "Col3"
args2(10).Value = 4
args2(11).Name = "Ascending3"
args2(11).Value = true
args2(12).Name = "IncludeComments"
args2(12).Value = false
dispatcher.executeDispatch(document, ".uno:DataSort", "", 0, args2())
end sub
Manually modified macro (that still only sorts 3 columns):
sub SortColumnC
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$B$5:$F$14"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(16) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ByRows"
args2(0).Value = true
args2(1).Name = "HasHeader"
args2(1).Value = false
args2(2).Name = "CaseSensitive"
args2(2).Value = false
args2(3).Name = "NaturalSort"
args2(3).Value = false
args2(4).Name = "IncludeAttribs"
args2(4).Value = true
args2(5).Name = "UserDefIndex"
args2(5).Value = 0
args2(6).Name = "Col1"
args2(6).Value = 2
args2(7).Name = "Ascending1"
args2(7).Value = true
args2(8).Name = "Col2"
args2(8).Value = 3
args2(9).Name = "Ascending2"
args2(9).Value = true
args2(10).Name = "Col3"
args2(10).Value = 4
args2(11).Name = "Ascending4"
args2(11).Value = true
args2(12).Name = "Col4"
args2(12).Value = 5
args2(13).Name = "Ascending5"
args2(13).Value = true
args2(14).Name = "Col5"
args2(14).Value = 6
args2(15).Name = "Ascending6"
args2(15).Value = true
args2(16).Name = "IncludeComments"
args2(16).Value = false
dispatcher.executeDispatch(document, ".uno:DataSort", "", 0, args2())
end sub