Macro / impressão de várias páginas.

Prezados,

Estou trabalhando em uma macro que realiza alterações entre as planilhas em uma pasta de trabalho e imprime imediatamente após realizar as alterações. No entanto estou enfrentando um problema, algumas planilhas demoram para serem impressas e a macro pula a mesma, seguindo para a próxima.
Quando coloco “Wait”, mesmo independente do tempo (cheguei a colocar 3000), o erro persiste. Como posso proceder?


    sub PREENCHERPROTOCOLO1
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")
    
Wait 1000
     rem ----------------------------------------------------------------------
    dispatcher.executeDispatch(document, ".uno:PrintDefault", "", 0, Array())

Wait 1000
  
    rem ----------------------------------------------------------------------
    dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Nr"
args2(0).Value = 9

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

rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$F$12"

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

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

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

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

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())

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

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())

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

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())

rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "ToPoint"
args11(0).Value = "$C$13"

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

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

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

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

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

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

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

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

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

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

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

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

dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args17())

rem ----------------------------------------------------------------------
dim args18(0) as new com.sun.star.beans.PropertyValue
args18(0).Name = "StringName"
args18(0).Value = "Intensidade"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args18())

rem ----------------------------------------------------------------------
dim args19(0) as new com.sun.star.beans.PropertyValue
args19(0).Name = "ToPoint"
args19(0).Value = "$C$13"

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

rem ----------------------------------------------------------------------
dim args20(0) as new com.sun.star.beans.PropertyValue
args20(0).Name = "ToPoint"
args20(0).Value = "$D$14"

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

rem ----------------------------------------------------------------------
dim args21(0) as new com.sun.star.beans.PropertyValue
args21(0).Name = "StringName"
args21(0).Value = "7 (SETE)"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args21())

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

dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args22())

rem ----------------------------------------------------------------------
dim args23(0) as new com.sun.star.beans.PropertyValue
args23(0).Name = "ToPoint"
args23(0).Value = "$C$16"

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

rem ----------------------------------------------------------------------
dim args24(0) as new com.sun.star.beans.PropertyValue
args24(0).Name = "StringName"
args24(0).Value = "Fator gerador"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args24())

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

dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args25())

rem ----------------------------------------------------------------------
dim args26(0) as new com.sun.star.beans.PropertyValue
args26(0).Name = "StringName"
args26(0).Value = "Meio"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args26())

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

dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args27())

rem ----------------------------------------------------------------------
dim args28(0) as new com.sun.star.beans.PropertyValue
args28(0).Name = "StringName"
args28(0).Value = "Via"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args28())

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

dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args29())

rem ----------------------------------------------------------------------
dim args30(0) as new com.sun.star.beans.PropertyValue
args30(0).Name = "ToPoint"
args30(0).Value = "$M$16"

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

rem ----------------------------------------------------------------------
dim args31(0) as new com.sun.star.beans.PropertyValue
args31(0).Name = "StringName"
args31(0).Value = "Via"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args31())

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

dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args32())

rem ----------------------------------------------------------------------
dim args33(0) as new com.sun.star.beans.PropertyValue
args33(0).Name = "StringName"
args33(0).Value = "Intervalo"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args33())

rem ----------------------------------------------------------------------
dim args34(0) as new com.sun.star.beans.PropertyValue
args34(0).Name = "ToPoint"
args34(0).Value = "$D$17"

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

rem ----------------------------------------------------------------------
dim args35(0) as new com.sun.star.beans.PropertyValue
args35(0).Name = "StringName"
args35(0).Value = "7 (SETE)"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args35())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:JumpToNextCell", "", 0, Array())

rem ----------------------------------------------------------------------
dim args37(0) as new com.sun.star.beans.PropertyValue
args37(0).Name = "ToPoint"
args37(0).Value = "$C$18"

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())

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

dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args39())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())

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

dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args41())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())

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

dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args43())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())

rem ----------------------------------------------------------------------
dim args45(0) as new com.sun.star.beans.PropertyValue
args45(0).Name = "ToPoint"
args45(0).Value = "$D$19"

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())

rem ----------------------------------------------------------------------
dim args47(0) as new com.sun.star.beans.PropertyValue
args47(0).Name = "ToPoint"
args47(0).Value = "$D$20"

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

rem ----------------------------------------------------------------------
dim args48(0) as new com.sun.star.beans.PropertyValue
args48(0).Name = "StringName"
args48(0).Value = "Topografia"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args48())

rem ----------------------------------------------------------------------
dim args49(0) as new com.sun.star.beans.PropertyValue
args49(0).Name = "ToPoint"
args49(0).Value = "$B$23"

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

rem ----------------------------------------------------------------------
dim args50(0) as new com.sun.star.beans.PropertyValue
args50(0).Name = "StringName"
args50(0).Value = "Justificativa"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args50())

rem ----------------------------------------------------------------------
dim args51(0) as new com.sun.star.beans.PropertyValue
args51(0).Name = "ToPoint"
args51(0).Value = "$P$20"

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

rem ----------------------------------------------------------------------
dim args52(0) as new com.sun.star.beans.PropertyValue
args52(0).Name = "StringName"
args52(0).Value = "=HOJE()"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args52())

rem ----------------------------------------------------------------------
dim args53(0) as new com.sun.star.beans.PropertyValue
args53(0).Name = "ToPoint"
args53(0).Value = "$M$9"

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

rem ----------------------------------------------------------------------
dim args54(0) as new com.sun.star.beans.PropertyValue
args54(0).Name = "StringName"
args54(0).Value = "=DADOS.G5"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args54())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:JumpToNextCell", "", 0, Array())

WAIT 200

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PrintDefault", "", 0, Array())

WAIT 200

rem ----------------------------------------------------------------------
dim args57(0) as new com.sun.star.beans.PropertyValue
args57(0).Name = "Nr"
args57(0).Value = 2

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args57())

rem ----------------------------------------------------------------------
dim args58(0) as new com.sun.star.beans.PropertyValue
args58(0).Name = "ToPoint"
args58(0).Value = "$B$41"

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

rem ----------------------------------------------------------------------
dim args59(0) as new com.sun.star.beans.PropertyValue
args59(0).Name = "StringName"
args59(0).Value = "nome protocolo"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args59())

rem ----------------------------------------------------------------------
dim args60(0) as new com.sun.star.beans.PropertyValue
args60(0).Name = "ToPoint"
args60(0).Value = "$B$54"

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

rem ----------------------------------------------------------------------
dim args61(0) as new com.sun.star.beans.PropertyValue
args61(0).Name = "StringName"
args61(0).Value = "descrição após dados"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args61())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:JumpToNextCell", "", 0, Array())

WAIT 1000

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PrintDefault", "", 0, Array())

WAIT 1000

rem ----------------------------------------------------------------------
dim args64(0) as new com.sun.star.beans.PropertyValue
args64(0).Name = "Nr"
args64(0).Value = 8

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args64())

rem ----------------------------------------------------------------------
dim args65(0) as new com.sun.star.beans.PropertyValue
args65(0).Name = "ToPoint"
args65(0).Value = "$C$270:$L$293"

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

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

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args67())

rem ----------------------------------------------------------------------
dim args68(0) as new com.sun.star.beans.PropertyValue
args68(0).Name = "ToPoint"
args68(0).Value = "$B$12"

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())

rem ----------------------------------------------------------------------
dim args70(0) as new com.sun.star.beans.PropertyValue
args70(0).Name = "Nr"
args70(0).Value = 8

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args70())

rem ----------------------------------------------------------------------
dim args71(0) as new com.sun.star.beans.PropertyValue
args71(0).Name = "ToPoint"
args71(0).Value = "$B$294:$L$296"

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

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

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args73())

rem ----------------------------------------------------------------------
dim args74(0) as new com.sun.star.beans.PropertyValue
args74(0).Name = "ToPoint"
args74(0).Value = "$A$36"

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())

rem ----------------------------------------------------------------------
dim args76(0) as new com.sun.star.beans.PropertyValue
args76(0).Name = "Nr"
args76(0).Value = 8

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args76())

rem ----------------------------------------------------------------------
dim args77(0) as new com.sun.star.beans.PropertyValue
args77(0).Name = "ToPoint"
args77(0).Value = "$P$270:$R$293"

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

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

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args79())

rem ----------------------------------------------------------------------
dim args80(0) as new com.sun.star.beans.PropertyValue
args80(0).Name = "ToPoint"
args80(0).Value = "$O$12"

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())

rem ----------------------------------------------------------------------
dim args82(0) as new com.sun.star.beans.PropertyValue
args82(0).Name = "Nr"
args82(0).Value = 8

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args82())

rem ----------------------------------------------------------------------
dim args83(0) as new com.sun.star.beans.PropertyValue
args83(0).Name = "ToPoint"
args83(0).Value = "$G$264"

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

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

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args85())

rem ----------------------------------------------------------------------
dim args86(0) as new com.sun.star.beans.PropertyValue
args86(0).Name = "ToPoint"
args86(0).Value = "$F$6"

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

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())

rem ----------------------------------------------------------------------
dim args88(0) as new com.sun.star.beans.PropertyValue
args88(0).Name = "ToPoint"
args88(0).Value = "$L$2"

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

rem ----------------------------------------------------------------------
dim args89(0) as new com.sun.star.beans.PropertyValue
args89(0).Name = "StringName"
args89(0).Value = "=DADOS.G5"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args89())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:JumpToNextCell", "", 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PrintDefault", "", 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PrintDefault", "", 0, Array())


    end sub

Ola @liban, o teste aqui com a macro sem mexer, realmente encavala tudo

Depois que fiz esta alterações, funcionou:

  1. Na aba [ PP ], selecione A1:Q38 e nomeie imp_Prescricao

  2. Na aba [ AIH ], selecione A1:K79 e nomeie imp_AIH

  3. Na aba [ ATB ], selecione A1:U41 e nomeie imp_ATB

  4. Na aba [ ANAMNESE ], selecione A1:K49 e nomeie imp_ANAMNESE

  5. Alterações na macro vide final dela.

    sub PREENCHERPROTOCOLO1
    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 args2(0) as new com.sun.star.beans.PropertyValue
    args2(0).Name = "Nr"
    args2(0).Value = 9
    dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args2())
    rem ----------------------------------------------------------------------
    dim args3(0) as new com.sun.star.beans.PropertyValue
    args3(0).Name = "ToPoint"
    args3(0).Value = "$F$12"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
    rem ----------------------------------------------------------------------
    dim args4(0) as new com.sun.star.beans.PropertyValue
    args4(0).Name = "StringName"
    args4(0).Value = "X"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args4())
     rem ----------------------------------------------------------------------
    dim args5(1) as new com.sun.star.beans.PropertyValue
    args5(0).Name = "By"
    args5(0).Value = 1
    args5(1).Name = "Sel"
    args5(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args5())
    dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, args5())
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args5())
    dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, args5())
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args5())
    dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
    rem ----------------------------------------------------------------------
    dim args11(0) as new com.sun.star.beans.PropertyValue
    args11(0).Name = "ToPoint"
    args11(0).Value = "$C$13"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args11())
    rem ----------------------------------------------------------------------
    dim args12(0) as new com.sun.star.beans.PropertyValue
    args12(0).Name = "StringName"
    args12(0).Value = "Cofator"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args12())
    rem ----------------------------------------------------------------------
    dim args13(1) as new com.sun.star.beans.PropertyValue
    args13(0).Name = "By"
    args13(0).Value = 1
    args13(1).Name = "Sel"
    args13(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args13())
    rem ----------------------------------------------------------------------
    dim args14(0) as new com.sun.star.beans.PropertyValue
    args14(0).Name = "StringName"
    args14(0).Value = "Intensidade"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args14())
    rem ----------------------------------------------------------------------
    dim args15(1) as new com.sun.star.beans.PropertyValue
    args15(0).Name = "By"
    args15(0).Value = 1
    args15(1).Name = "Sel"
    args15(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args15())
    rem ----------------------------------------------------------------------
    dim args16(0) as new com.sun.star.beans.PropertyValue
    args16(0).Name = "StringName"
    args16(0).Value = "Via"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args16())
    rem ----------------------------------------------------------------------
    dim args17(1) as new com.sun.star.beans.PropertyValue
    args17(0).Name = "By"
    args17(0).Value = 1
    args17(1).Name = "Sel"
    args17(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args17())
    rem ----------------------------------------------------------------------
    dim args18(0) as new com.sun.star.beans.PropertyValue
    args18(0).Name = "StringName"
    args18(0).Value = "Intensidade"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args18())
    rem ----------------------------------------------------------------------
    dim args19(0) as new com.sun.star.beans.PropertyValue
    args19(0).Name = "ToPoint"
    args19(0).Value = "$C$13"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args19())
    rem ----------------------------------------------------------------------
    dim args20(0) as new com.sun.star.beans.PropertyValue
    args20(0).Name = "ToPoint"
    args20(0).Value = "$D$14"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args20())
    rem ----------------------------------------------------------------------
    dim args21(0) as new com.sun.star.beans.PropertyValue
    args21(0).Name = "StringName"
    args21(0).Value = "7 (SETE)"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args21())
    rem ----------------------------------------------------------------------
    dim args22(1) as new com.sun.star.beans.PropertyValue
    args22(0).Name = "By"
    args22(0).Value = 1
    args22(1).Name = "Sel"
    args22(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args22())
    rem ----------------------------------------------------------------------
    dim args23(0) as new com.sun.star.beans.PropertyValue
    args23(0).Name = "ToPoint"
    args23(0).Value = "$C$16"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args23())
    rem ----------------------------------------------------------------------
    dim args24(0) as new com.sun.star.beans.PropertyValue
    args24(0).Name = "StringName"
    args24(0).Value = "Fator gerador"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args24())
    rem ----------------------------------------------------------------------
    dim args25(1) as new com.sun.star.beans.PropertyValue
    args25(0).Name = "By"
    args25(0).Value = 1
    args25(1).Name = "Sel"
    args25(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args25())
    rem ----------------------------------------------------------------------
    dim args26(0) as new com.sun.star.beans.PropertyValue
    args26(0).Name = "StringName"
    args26(0).Value = "Meio"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args26())
    rem ----------------------------------------------------------------------
    dim args27(1) as new com.sun.star.beans.PropertyValue
    args27(0).Name = "By"
    args27(0).Value = 1
    args27(1).Name = "Sel"
    args27(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args27())
    rem ----------------------------------------------------------------------
    dim args28(0) as new com.sun.star.beans.PropertyValue
    args28(0).Name = "StringName"
    args28(0).Value = "Via"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args28())
    rem ----------------------------------------------------------------------
    dim args29(1) as new com.sun.star.beans.PropertyValue
    args29(0).Name = "By"
    args29(0).Value = 1
    args29(1).Name = "Sel"
    args29(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args29())
    rem ----------------------------------------------------------------------
    dim args30(0) as new com.sun.star.beans.PropertyValue
    args30(0).Name = "ToPoint"
    args30(0).Value = "$M$16"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args30())
    rem ----------------------------------------------------------------------
    dim args31(0) as new com.sun.star.beans.PropertyValue
    args31(0).Name = "StringName"
    args31(0).Value = "Via"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args31())
    rem ----------------------------------------------------------------------
    dim args32(1) as new com.sun.star.beans.PropertyValue
    args32(0).Name = "By"
    args32(0).Value = 1
    args32(1).Name = "Sel"
    args32(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args32())
    rem ----------------------------------------------------------------------
    dim args33(0) as new com.sun.star.beans.PropertyValue
    args33(0).Name = "StringName"
    args33(0).Value = "Intervalo"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args33())
    rem ----------------------------------------------------------------------
    dim args34(0) as new com.sun.star.beans.PropertyValue
    args34(0).Name = "ToPoint"
    args34(0).Value = "$D$17"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args34())
    rem ----------------------------------------------------------------------
    dim args35(0) as new com.sun.star.beans.PropertyValue
    args35(0).Name = "StringName"
    args35(0).Value = "7 (SETE)"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args35())
    dispatcher.executeDispatch(document, ".uno:JumpToNextCell", "", 0, Array())
    rem ----------------------------------------------------------------------
    dim args37(0) as new com.sun.star.beans.PropertyValue
    args37(0).Name = "ToPoint"
    args37(0).Value = "$C$18"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args37())
    dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
    rem ----------------------------------------------------------------------
    dim args39(1) as new com.sun.star.beans.PropertyValue
    args39(0).Name = "By"
    args39(0).Value = 1
    args39(1).Name = "Sel"
    args39(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args39())
    dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
    rem ----------------------------------------------------------------------
    dim args41(1) as new com.sun.star.beans.PropertyValue
    args41(0).Name = "By"
    args41(0).Value = 1
    args41(1).Name = "Sel"
    args41(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args41())
    dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, args41())
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args41())
    dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
    rem ----------------------------------------------------------------------
    dim args45(0) as new com.sun.star.beans.PropertyValue
    args45(0).Name = "ToPoint"
    args45(0).Value = "$D$19"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args45())
    dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
    rem ----------------------------------------------------------------------
    dim args47(0) as new com.sun.star.beans.PropertyValue
    args47(0).Name = "ToPoint"
    args47(0).Value = "$D$20"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args47())
    rem ----------------------------------------------------------------------
    dim args48(0) as new com.sun.star.beans.PropertyValue
    args48(0).Name = "StringName"
    args48(0).Value = "Topografia"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args48())
    rem ----------------------------------------------------------------------
    dim args49(0) as new com.sun.star.beans.PropertyValue
    args49(0).Name = "ToPoint"
    args49(0).Value = "$B$23"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args49())
    rem ----------------------------------------------------------------------
    dim args50(0) as new com.sun.star.beans.PropertyValue
    args50(0).Name = "StringName"
    args50(0).Value = "Justificativa"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args50())
    rem ----------------------------------------------------------------------
    dim args51(0) as new com.sun.star.beans.PropertyValue
    args51(0).Name = "ToPoint"
    args51(0).Value = "$P$20"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args51())
    rem ----------------------------------------------------------------------
    dim args52(0) as new com.sun.star.beans.PropertyValue
    args52(0).Name = "StringName"
    args52(0).Value = "=HOJE()"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args52())
    rem ----------------------------------------------------------------------
    dim args53(0) as new com.sun.star.beans.PropertyValue
    args53(0).Name = "ToPoint"
    args53(0).Value = "$M$9"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args53())
    rem ----------------------------------------------------------------------
    dim args54(0) as new com.sun.star.beans.PropertyValue
    args54(0).Name = "StringName"
    args54(0).Value = "=DADOS.G5"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args54())
    dispatcher.executeDispatch(document, ".uno:JumpToNextCell", "", 0, args54())
    rem ----------------------------------------------------------------------
    dim args57(0) as new com.sun.star.beans.PropertyValue
    args57(0).Name = "Nr"
    args57(0).Value = 2
    dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args57())
    rem ----------------------------------------------------------------------
    dim args58(0) as new com.sun.star.beans.PropertyValue
    args58(0).Name = "ToPoint"
    args58(0).Value = "$B$41"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args58())
    rem ----------------------------------------------------------------------
    dim args59(0) as new com.sun.star.beans.PropertyValue
    args59(0).Name = "StringName"
    args59(0).Value = "nome protocolo"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args59())
    rem ----------------------------------------------------------------------
    dim args60(0) as new com.sun.star.beans.PropertyValue
    args60(0).Name = "ToPoint"
    args60(0).Value = "$B$54"
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args60())
    rem ----------------------------------------------------------------------
    dim args61(0) as new com.sun.star.beans.PropertyValue
    args61(0).Name = "StringName"
    args61(0).Value = "descrição após dados"
    dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args61())
    dispatcher.executeDispatch(document, ".uno:JumpToNextCell", "", 0, args61())
    

rem ----------------------------------------------------------------------
dim args64(0) as new com.sun.star.beans.PropertyValue
args64(0).Name = “Nr”
args64(0).Value = 8
dispatcher.executeDispatch(document, “.uno:JumpToTable”, “”, 0, args64())
rem ----------------------------------------------------------------------
dim args65(0) as new com.sun.star.beans.PropertyValue
args65(0).Name = “ToPoint”
args65(0).Value = “$C$270:$L$293”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args65())
dispatcher.executeDispatch(document, “.uno:Copy”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args67(0) as new com.sun.star.beans.PropertyValue
args67(0).Name = “Nr”
args67(0).Value = 1
dispatcher.executeDispatch(document, “.uno:JumpToTable”, “”, 0, args67())
rem ----------------------------------------------------------------------
dim args68(0) as new com.sun.star.beans.PropertyValue
args68(0).Name = “ToPoint”
args68(0).Value = “$B$12”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args68())
dispatcher.executeDispatch(document, “.uno:Paste”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args70(0) as new com.sun.star.beans.PropertyValue
args70(0).Name = “Nr”
args70(0).Value = 8
dispatcher.executeDispatch(document, “.uno:JumpToTable”, “”, 0, args70())
rem ----------------------------------------------------------------------
dim args71(0) as new com.sun.star.beans.PropertyValue
args71(0).Name = “ToPoint”
args71(0).Value = “$B$294:$L$296”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args71())
dispatcher.executeDispatch(document, “.uno:Copy”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args73(0) as new com.sun.star.beans.PropertyValue
args73(0).Name = “Nr”
args73(0).Value = 1
dispatcher.executeDispatch(document, “.uno:JumpToTable”, “”, 0, args73())
rem ----------------------------------------------------------------------
dim args74(0) as new com.sun.star.beans.PropertyValue
args74(0).Name = “ToPoint”
args74(0).Value = “$A$36”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args74())
dispatcher.executeDispatch(document, “.uno:Paste”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args76(0) as new com.sun.star.beans.PropertyValue
args76(0).Name = “Nr”
args76(0).Value = 8
dispatcher.executeDispatch(document, “.uno:JumpToTable”, “”, 0, args76())
rem ----------------------------------------------------------------------
dim args77(0) as new com.sun.star.beans.PropertyValue
args77(0).Name = “ToPoint”
args77(0).Value = “$P$270:$R$293”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args77())
dispatcher.executeDispatch(document, “.uno:Copy”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args79(0) as new com.sun.star.beans.PropertyValue
args79(0).Name = “Nr”
args79(0).Value = 1
dispatcher.executeDispatch(document, “.uno:JumpToTable”, “”, 0, args79())
rem ----------------------------------------------------------------------
dim args80(0) as new com.sun.star.beans.PropertyValue
args80(0).Name = “ToPoint”
args80(0).Value = “$O$12”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args80())
dispatcher.executeDispatch(document, “.uno:Paste”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args82(0) as new com.sun.star.beans.PropertyValue
args82(0).Name = “Nr”
args82(0).Value = 8
dispatcher.executeDispatch(document, “.uno:JumpToTable”, “”, 0, args82())
rem ----------------------------------------------------------------------
dim args83(0) as new com.sun.star.beans.PropertyValue
args83(0).Name = “ToPoint”
args83(0).Value = “$G$264”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args83())
dispatcher.executeDispatch(document, “.uno:Copy”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args85(0) as new com.sun.star.beans.PropertyValue
args85(0).Name = “Nr”
args85(0).Value = 1
dispatcher.executeDispatch(document, “.uno:JumpToTable”, “”, 0, args85())
rem ----------------------------------------------------------------------
dim args86(0) as new com.sun.star.beans.PropertyValue
args86(0).Name = “ToPoint”
args86(0).Value = “$F$6”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args86())
dispatcher.executeDispatch(document, “.uno:Paste”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args88(0) as new com.sun.star.beans.PropertyValue
args88(0).Name = “ToPoint”
args88(0).Value = “$L$2”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args88())
rem ----------------------------------------------------------------------
dim args89(0) as new com.sun.star.beans.PropertyValue
args89(0).Name = “StringName”
args89(0).Value = “=DADOS.G5”
dispatcher.executeDispatch(document, “.uno:EnterString”, “”, 0, args89())
dispatcher.executeDispatch(document, “.uno:JumpToNextCell”, “”, 0, args89())

'----------acima foi eliminado os comando para impressão e contagem de tempo (wait)
'----------incluído as instruções abaixo

	Call IrPara "imp_Prescricao" 
	dispatcher.executeDispatch(document, ".uno:PrintDefault", "", 0, Array())
	Wait 5000
	dispatcher.executeDispatch(document, ".uno:PrintDefault", "", 0, Array())
	Wait 5000
	Call IrPara "imp_AIH" 
	dispatcher.executeDispatch(document, ".uno:PrintDefault", "", 0, Array())
	Wait 5000
	Call IrPara "imp_ATB" 
	dispatcher.executeDispatch(document, ".uno:PrintDefault", "", 0, Array())
	Wait 5000
	Call IrPara "imp_ANAMNESE" 
	dispatcher.executeDispatch(document, ".uno:PrintDefault", "", 0, Array())
	Wait 5000

    end sub

Mais a SubMacro:

'================================================|
sub IrPara (xlocal as string) 'xlocal = Planilha.A1
'exemplo uso: IrPara "Planilha.A1" ou "Planila1.A1:B3" ou "NomeArea"
'================================================|
Dim document As Object
Dim dispatcher As Object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = xlocal
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
end sub

Gilberto, sabe o que acontece, ao invés de mudar de aba, ele acaba imprimindo algumas páginas repetidamente. Ou seja, se tenho a pagina 1, 2 e 3, ao mandar imprimir, ele imprime 1,1 e 3.
Mesmo ajustando o Wait.
Consegue me dar uma luz?

Oi @liban, é possível me enviar cópia do arquivo, altere dados sigilosos, envia para gilbertoschiavinatto@yahoo.com.br , fica mais fácil verificar alguma incoerência da macro e impressões, me parece que a comandos desnecessários. Posso dar uma olhada após almoço…

O primeiro PrintDefault refere-se a que área de impressão ? Como não esta identificado dependendo de onde estiver o cursor e acionar a macro, vai dar diferença.