Montei macro para impressão com um While / Wend, na primeira passada ok, na segunda gera este erro, estou usando Win10 + LibO 6.2.4.2 (64)
Alguém saberia traduzir…
A macro completa é esta:
sub Imprimir
dim document, dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:Save", "", 0, Array())
Wait 1000
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "Cabeça"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$LISTAGEM.$A$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
dim args7(5) as new com.sun.star.beans.PropertyValue
args7(0).Name = "Flags"
args7(0).Value = "A"
args7(1).Name = "FormulaCommand"
args7(1).Value = 0
args7(2).Name = "SkipEmptyCells"
args7(2).Value = false
args7(3).Name = "Transpose"
args7(3).Value = false
args7(4).Name = "AsLink"
args7(4).Value = false
args7(5).Name = "MoveMode"
args7(5).Value = 0
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args7())
dim args8(1) as new com.sun.star.beans.PropertyValue
args8(0).Name = "By"
args8(0).Value = 23
args8(1).Name = "Sel"
args8(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args8())
oSel = ThisComponent.getCurrentSelection()
Var1 = oSel.getString()
While Var1 <> ""
dim args13(5) as new com.sun.star.beans.PropertyValue
args13(0).Name = "Flags"
args13(0).Value = "A"
args13(1).Name = "FormulaCommand"
args13(1).Value = 0
args13(2).Name = "SkipEmptyCells"
args13(2).Value = false
args13(3).Name = "Transpose"
args13(3).Value = false
args13(4).Name = "AsLink"
args13(4).Value = false
args13(5).Name = "MoveMode"
args13(5).Value = 0
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args13()) '<===== ERRO AQUI
dim args18(1) as new com.sun.star.beans.PropertyValue
args18(0).Name = "By"
args18(0).Value = 23
args18(1).Name = "Sel"
args18(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args18())
oSel = ThisComponent.getCurrentSelection()
Var1 = oSel.getString()
Wend
dim args21(0) as new com.sun.star.beans.PropertyValue
args21(0).Name = "ToPoint"
args21(0).Value = "Rodape"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args21())
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
dim args23(0) as new com.sun.star.beans.PropertyValue
args23(0).Name = "ToPoint"
args23(0).Value = "$LISTAGEM.$A$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args23())
dispatcher.executeDispatch(document, ".uno:GoDownToEndOfData", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
dim args27(0) as new com.sun.star.beans.PropertyValue
args27(0).Name = "ToPoint"
args27(0).Value = "$LISTAGEM.$A$1:$J$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args27())
dispatcher.executeDispatch(document, ".uno:GoDownToEndOfDataSel", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:DefinePrintArea", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:Print", "", 0, Array())
end Sub