Macro não executa

prezados,
utilizei o “gravar macro” para criar uma macro que me proporcionasse o ordenamento automático de datas em cerca de 30 linhas (abri o gravador de macro e selecionei umas 30 linhas e ordenei-as por datas na coluna I e depois fechei e gravei a macro com o nome “ordenar”) , só que a macro não executa. Gostaria que me informassem o porquê da falha, obrigado.

sub ordenar
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 = "$G$7"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "By"
args2(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args2())

rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "By"
args3(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args3())

rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "By"
args4(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args4())

rem ----------------------------------------------------------------------
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "By"
args5(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args5())

rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "By"
args6(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args6())

rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "By"
args7(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args7())

rem ----------------------------------------------------------------------
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "By"
args8(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args8())

rem ----------------------------------------------------------------------
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = "By"
args9(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args9())

rem ----------------------------------------------------------------------
dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "By"
args10(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args10())

rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "By"
args11(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args11())

rem ----------------------------------------------------------------------
dim args12(0) as new com.sun.star.beans.PropertyValue
args12(0).Name = "By"
args12(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args12())

rem ----------------------------------------------------------------------
dim args13(0) as new com.sun.star.beans.PropertyValue
args13(0).Name = "By"
args13(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args13())

rem ----------------------------------------------------------------------
dim args14(0) as new com.sun.star.beans.PropertyValue
args14(0).Name = "By"
args14(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args14())

rem ----------------------------------------------------------------------
dim args15(0) as new com.sun.star.beans.PropertyValue
args15(0).Name = "By"
args15(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args15())

rem ----------------------------------------------------------------------
dim args16(0) as new com.sun.star.beans.PropertyValue
args16(0).Name = "By"
args16(0).Value = 1

dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args16())

Complemento

Bom dia Conrado,
estou enviando anexo a planilha, que é uma planilha simples e pequena, para análise. Estou salvado-a em ods. Agradeço a ajuda.
ORÇAMENTO MENSAL.ods

@maudeme, bem vinda.

Teria como enviar a planilha de exemplo, pois sua macro está faltando alguma linha. Ela deve terminar em “End Sub”. Outra informação: estão salvando a planilha em “.ods” ou “.xls”?

@maudeme

Segue a minha gravação de macro

sub Main
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$1:$B$31"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

rem ----------------------------------------------------------------------
dim args2(9) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ByRows"
args2(0).Value = true
args2(1).Name = "HasHeader"
args2(1).Value = true
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 = "IncludeComments"
args2(8).Value = false
args2(9).Name = "IncludeImages"
args2(9).Value = true

dispatcher.executeDispatch(document, ".uno:DataSort", "", 0, args2())

end sub

Ola @maudeme, segue arquivo com uma sugestão:

Com esta macro:

Sub Ordenar
'O############################################################################O
	IrPara "MercadoOutros" ' <====== Area nomeada G6:I32 =========<<<<
dim args2(9) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ByRows"
args2(0).Value = true
args2(1).Name = "HasHeader"
args2(1).Value = true
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 = 9
args2(7).Name = "Ascending1"
args2(7).Value = true
args2(8).Name = "IncludeComments"
args2(8).Value = false
args2(9).Name = "IncludeImages"
args2(9).Value = true
CreateUnoService("com.sun.star.frame.DispatchHelper") _
.executeDispatch(ThisComponent.CurrentController.Frame, ".uno:DataSort", "", 0, args2())
	IrPara "G5"
End Sub

Sub IrPara ( X As String )
'O############################################################################O
dim args1(0) as new com.sun.star.beans.PropertyValue : args1(0).Name = "ToPoint"
args1(0).Value = X
CreateUnoService("com.sun.star.frame.DispatchHelper") _
.executeDispatch(ThisComponent.CurrentController.Frame, ".uno:GoToCell", "", 0, args1())
End Sub

ATENÇÂO:: Para dar mais detalhes a sua pergunta, use Descrição da imagem na pergunta ou Descrição da imagem abaixo. Não use Adicionar resposta para comentário. Grato.

Caso a resposta atendeu sua necessidade, por gentileza, click na bolinha Descrição da imagem a esquerda da resposta, para finalizar a pergunta.