What I want to do is
To test the value from Sheet (NR1) cell (T19), if that value is =>1, Then execute the recorded macro “PrtRangex”
If that is not true then, execute macro “PrtRange1x”.
If the value Sheet (NR1) cell (T19) is =>1 and the value Sheet (NR1) cell (N16) is also =>1, Then execute macro “PrtRange2”.
If the value from sheet (NR2) cell (V35) =>1, Then execute “PrtRange3x”.
My recorded macros below>
Code: Select all
sub PrtRangex
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 = "Nr"
args1(0).Value = 1
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args1())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(2) as new com.sun.star.beans.PropertyValue
args3(0).Name = "PrintArea"
args3(0).Value = "$A$2:$t$58"
args3(1).Name = "PrintRepeatRow"
args3(1).Value = ""
args3(2).Name = "PrintRepeatCol"
args3(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Nr"
args4(0).Value = 2
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args4())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args6(2) as new com.sun.star.beans.PropertyValue
args6(0).Name = "PrintArea"
args6(0).Value = ""
args6(1).Name = "PrintRepeatRow"
args6(1).Value = ""
args6(2).Name = "PrintRepeatCol"
args6(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "Nr"
args7(0).Value = 3
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args7())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args9(2) as new com.sun.star.beans.PropertyValue
args9(0).Name = "PrintArea"
args9(0).Value = ""
args9(1).Name = "PrintRepeatRow"
args9(1).Value = ""
args9(2).Name = "PrintRepeatCol"
args9(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "Nr"
args10(0).Value = 4
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args10())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args12(2) as new com.sun.star.beans.PropertyValue
args12(0).Name = "PrintArea"
args12(0).Value = ""
args12(1).Name = "PrintRepeatRow"
args12(1).Value = ""
args12(2).Name = "PrintRepeatCol"
args12(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args12())
rem ----------------------------------------------------------------------
end sub
rem next print 1--------------------------------------
sub PrtRange1x
rem page 1,2
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 = "Nr"
args1(0).Value = 1
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args1())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(2) as new com.sun.star.beans.PropertyValue
args3(0).Name = "PrintArea"
args3(0).Value = "$A$2:$t$58"
args3(1).Name = "PrintRepeatRow"
args3(1).Value = ""
args3(2).Name = "PrintRepeatCol"
args3(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Nr"
args4(0).Value = 2
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args4())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args6(2) as new com.sun.star.beans.PropertyValue
args6(0).Name = "PrintArea"
args6(0).Value = "$A$1:$V$54"
args6(1).Name = "PrintRepeatRow"
args6(1).Value = ""
args6(2).Name = "PrintRepeatCol"
args6(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "Nr"
args7(0).Value = 3
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args7())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args9(2) as new com.sun.star.beans.PropertyValue
args9(0).Name = "PrintArea"
args9(0).Value = ""
args9(1).Name = "PrintRepeatRow"
args9(1).Value = ""
args9(2).Name = "PrintRepeatCol"
args9(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "Nr"
args10(0).Value = 4
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args10())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args12(2) as new com.sun.star.beans.PropertyValue
args12(0).Name = "PrintArea"
args12(0).Value = ""
args12(1).Name = "PrintRepeatRow"
args12(1).Value = ""
args12(2).Name = "PrintRepeatCol"
args12(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args12())
rem ----------------------------------------------------------------------
end sub
rem next 2-----------------------------------------------------------
sub PrtRange2x
rem page 1,2,3-----------
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 = "Nr"
args1(0).Value = 1
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args1())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(2) as new com.sun.star.beans.PropertyValue
args3(0).Name = "PrintArea"
args3(0).Value = "$A$2:$t$58"
args3(1).Name = "PrintRepeatRow"
args3(1).Value = ""
args3(2).Name = "PrintRepeatCol"
args3(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Nr"
args4(0).Value = 2
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args4())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args6(2) as new com.sun.star.beans.PropertyValue
args6(0).Name = "PrintArea"
args6(0).Value = "$A$1:$V$54"
args6(1).Name = "PrintRepeatRow"
args6(1).Value = ""
args6(2).Name = "PrintRepeatCol"
args6(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "Nr"
args7(0).Value = 3
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args7())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args9(2) as new com.sun.star.beans.PropertyValue
args9(0).Name = "PrintArea"
args9(0).Value = "$A$2:$W$61"
args9(1).Name = "PrintRepeatRow"
args9(1).Value = ""
args9(2).Name = "PrintRepeatCol"
args9(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "Nr"
args10(0).Value = 4
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args10())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args12(2) as new com.sun.star.beans.PropertyValue
args12(0).Name = "PrintArea"
args12(0).Value = ""
args12(1).Name = "PrintRepeatRow"
args12(1).Value = ""
args12(2).Name = "PrintRepeatCol"
args12(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args12())
rem ----------------------------------------------------------------------
dim args13(0) as new com.sun.star.beans.PropertyValue
args13(0).Name = "Nr"
args13(0).Value = 1
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args13())
rem ----------------------------------------------------------------------
dim args14(0) as new com.sun.star.beans.PropertyValue
args14(0).Name = "ToPoint"
args14(0).Value = "$V$3"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args14())
end sub
rem next 3----------------------------------------
sub PrtRange3x
rem page 1,2,4
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 = "Nr"
args1(0).Value = 1
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args1())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(2) as new com.sun.star.beans.PropertyValue
args3(0).Name = "PrintArea"
args3(0).Value = "$A$2:$t$58"
args3(1).Name = "PrintRepeatRow"
args3(1).Value = ""
args3(2).Name = "PrintRepeatCol"
args3(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Nr"
args4(0).Value = 2
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args4())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args6(2) as new com.sun.star.beans.PropertyValue
args6(0).Name = "PrintArea"
args6(0).Value = "$A$1:$V$54"
args6(1).Name = "PrintRepeatRow"
args6(1).Value = ""
args6(2).Name = "PrintRepeatCol"
args6(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "Nr"
args7(0).Value = 3
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args7())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args9(2) as new com.sun.star.beans.PropertyValue
args9(0).Name = "PrintArea"
args9(0).Value = ""
args9(1).Name = "PrintRepeatRow"
args9(1).Value = ""
args9(2).Name = "PrintRepeatCol"
args9(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "Nr"
args10(0).Value = 4
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args10())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:EditPrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args12(2) as new com.sun.star.beans.PropertyValue
args12(0).Name = "PrintArea"
args12(0).Value = "$A$3:$v$52"
args12(1).Name = "PrintRepeatRow"
args12(1).Value = ""
args12(2).Name = "PrintRepeatCol"
args12(2).Value = ""
dispatcher.executeDispatch(document, ".uno:ChangePrintArea", "", 0, args12())
end sub