roeret Newbie

Joined: 04 Nov 2008 Posts: 1
|
Posted: Tue Nov 04, 2008 6:01 am Post subject: "advanced" printing by macro |
|
|
Hi folks
I'm completely new to this kind off macros. I come from QPW and is migrating to OO (to completely migrate to linux)...
What I need now is an advanced macro who check a cell and if the value 1 is present go to a new sheet and print special selected cells (macro for that is recorded and added below). After that go one cell down and same here (just the next sheet printed then). If the cell is blank the macro should just go yet another cell down. The macro should test 79 cells)
Start off testing is the sheet "stamdata" B4 (stop B83)
Start off printing is sheet: J
I come from QPW where I used QPW macros who works under WYSIWYG and I just build the macros up by a lot off if functions; clean and simple. After what I have read about OO macros it isn't THAT simpel ...
PLEASE can anyone help me??!!!!
Before the testing should the macro print:
REM ***** BASIC *****
Sub Main
End Sub
sub test
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 = 10
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PageFormatDialog", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$F$4:$J$35"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(1) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Copies"
args4(0).Value = 1
args4(1).Name = "Collate"
args4(1).Value = true
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args4())
end sub
sub printman
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 = "$A$1:$K$40"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "By"
args2(0).Value = 1
args2(1).Name = "Sel"
args2(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "By"
args3(0).Value = 1
args3(1).Name = "Sel"
args3(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(1) as new com.sun.star.beans.PropertyValue
args4(0).Name = "By"
args4(0).Value = 1
args4(1).Name = "Sel"
args4(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args5())
rem ----------------------------------------------------------------------
dim args6(1) as new com.sun.star.beans.PropertyValue
args6(0).Name = "By"
args6(0).Value = 1
args6(1).Name = "Sel"
args6(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args6())
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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args7())
rem ----------------------------------------------------------------------
dim args8(1) as new com.sun.star.beans.PropertyValue
args8(0).Name = "By"
args8(0).Value = 1
args8(1).Name = "Sel"
args8(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args8())
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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(1) as new com.sun.star.beans.PropertyValue
args10(0).Name = "By"
args10(0).Value = 1
args10(1).Name = "Sel"
args10(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args10())
rem ----------------------------------------------------------------------
dim args11(1) as new com.sun.star.beans.PropertyValue
args11(0).Name = "By"
args11(0).Value = 1
args11(1).Name = "Sel"
args11(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args11())
rem ----------------------------------------------------------------------
dim args12(1) as new com.sun.star.beans.PropertyValue
args12(0).Name = "Copies"
args12(0).Value = 1
args12(1).Name = "Collate"
args12(1).Value = true
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args12())
end sub
The printing macro sheet J:
REM ***** BASIC *****
Sub Main
End Sub
sub test
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 = 10
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:PageFormatDialog", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$F$4:$J$35"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(1) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Copies"
args4(0).Value = 1
args4(1).Name = "Collate"
args4(1).Value = true
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args4())
end sub
sub printman
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 = "$A$1:$K$40"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "By"
args2(0).Value = 1
args2(1).Name = "Sel"
args2(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "By"
args3(0).Value = 1
args3(1).Name = "Sel"
args3(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(1) as new com.sun.star.beans.PropertyValue
args4(0).Name = "By"
args4(0).Value = 1
args4(1).Name = "Sel"
args4(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args5())
rem ----------------------------------------------------------------------
dim args6(1) as new com.sun.star.beans.PropertyValue
args6(0).Name = "By"
args6(0).Value = 1
args6(1).Name = "Sel"
args6(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args6())
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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args7())
rem ----------------------------------------------------------------------
dim args8(1) as new com.sun.star.beans.PropertyValue
args8(0).Name = "By"
args8(0).Value = 1
args8(1).Name = "Sel"
args8(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args8())
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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(1) as new com.sun.star.beans.PropertyValue
args10(0).Name = "By"
args10(0).Value = 1
args10(1).Name = "Sel"
args10(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args10())
rem ----------------------------------------------------------------------
dim args11(1) as new com.sun.star.beans.PropertyValue
args11(0).Name = "By"
args11(0).Value = 1
args11(1).Name = "Sel"
args11(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args11())
rem ----------------------------------------------------------------------
dim args12(1) as new com.sun.star.beans.PropertyValue
args12(0).Name = "Copies"
args12(0).Value = 1
args12(1).Name = "Collate"
args12(1).Value = true
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args12())
end sub
sub printj
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 = "$F$4"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "By"
args2(0).Value = 1
args2(1).Name = "Sel"
args2(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "By"
args3(0).Value = 1
args3(1).Name = "Sel"
args3(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(1) as new com.sun.star.beans.PropertyValue
args4(0).Name = "By"
args4(0).Value = 1
args4(1).Name = "Sel"
args4(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoRight", "", 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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args5())
rem ----------------------------------------------------------------------
dim args6(1) as new com.sun.star.beans.PropertyValue
args6(0).Name = "By"
args6(0).Value = 1
args6(1).Name = "Sel"
args6(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args6())
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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args7())
rem ----------------------------------------------------------------------
dim args8(1) as new com.sun.star.beans.PropertyValue
args8(0).Name = "By"
args8(0).Value = 1
args8(1).Name = "Sel"
args8(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args8())
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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(1) as new com.sun.star.beans.PropertyValue
args10(0).Name = "By"
args10(0).Value = 1
args10(1).Name = "Sel"
args10(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args10())
rem ----------------------------------------------------------------------
dim args11(1) as new com.sun.star.beans.PropertyValue
args11(0).Name = "By"
args11(0).Value = 1
args11(1).Name = "Sel"
args11(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args11())
rem ----------------------------------------------------------------------
dim args12(1) as new com.sun.star.beans.PropertyValue
args12(0).Name = "By"
args12(0).Value = 1
args12(1).Name = "Sel"
args12(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args13())
rem ----------------------------------------------------------------------
dim args14(1) as new com.sun.star.beans.PropertyValue
args14(0).Name = "By"
args14(0).Value = 1
args14(1).Name = "Sel"
args14(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args15())
rem ----------------------------------------------------------------------
dim args16(1) as new com.sun.star.beans.PropertyValue
args16(0).Name = "By"
args16(0).Value = 1
args16(1).Name = "Sel"
args16(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args17())
rem ----------------------------------------------------------------------
dim args18(1) as new com.sun.star.beans.PropertyValue
args18(0).Name = "By"
args18(0).Value = 1
args18(1).Name = "Sel"
args18(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args18())
rem ----------------------------------------------------------------------
dim args19(1) as new com.sun.star.beans.PropertyValue
args19(0).Name = "By"
args19(0).Value = 1
args19(1).Name = "Sel"
args19(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args19())
rem ----------------------------------------------------------------------
dim args20(1) as new com.sun.star.beans.PropertyValue
args20(0).Name = "By"
args20(0).Value = 1
args20(1).Name = "Sel"
args20(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args20())
rem ----------------------------------------------------------------------
dim args21(1) as new com.sun.star.beans.PropertyValue
args21(0).Name = "By"
args21(0).Value = 1
args21(1).Name = "Sel"
args21(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args22())
rem ----------------------------------------------------------------------
dim args23(1) as new com.sun.star.beans.PropertyValue
args23(0).Name = "By"
args23(0).Value = 1
args23(1).Name = "Sel"
args23(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args23())
rem ----------------------------------------------------------------------
dim args24(1) as new com.sun.star.beans.PropertyValue
args24(0).Name = "By"
args24(0).Value = 1
args24(1).Name = "Sel"
args24(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args25())
rem ----------------------------------------------------------------------
dim args26(1) as new com.sun.star.beans.PropertyValue
args26(0).Name = "By"
args26(0).Value = 1
args26(1).Name = "Sel"
args26(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args27())
rem ----------------------------------------------------------------------
dim args28(1) as new com.sun.star.beans.PropertyValue
args28(0).Name = "By"
args28(0).Value = 1
args28(1).Name = "Sel"
args28(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args29())
rem ----------------------------------------------------------------------
dim args30(1) as new com.sun.star.beans.PropertyValue
args30(0).Name = "By"
args30(0).Value = 1
args30(1).Name = "Sel"
args30(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args30())
rem ----------------------------------------------------------------------
dim args31(1) as new com.sun.star.beans.PropertyValue
args31(0).Name = "By"
args31(0).Value = 1
args31(1).Name = "Sel"
args31(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 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 = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args32())
rem ----------------------------------------------------------------------
dim args33(1) as new com.sun.star.beans.PropertyValue
args33(0).Name = "By"
args33(0).Value = 1
args33(1).Name = "Sel"
args33(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args33())
rem ----------------------------------------------------------------------
dim args34(1) as new com.sun.star.beans.PropertyValue
args34(0).Name = "By"
args34(0).Value = 1
args34(1).Name = "Sel"
args34(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args34())
rem ----------------------------------------------------------------------
dim args35(1) as new com.sun.star.beans.PropertyValue
args35(0).Name = "By"
args35(0).Value = 1
args35(1).Name = "Sel"
args35(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args35())
rem ----------------------------------------------------------------------
dim args36(1) as new com.sun.star.beans.PropertyValue
args36(0).Name = "By"
args36(0).Value = 1
args36(1).Name = "Sel"
args36(1).Value = true
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args36())
rem ----------------------------------------------------------------------
dim args37(1) as new com.sun.star.beans.PropertyValue
args37(0).Name = "Copies"
args37(0).Value = 1
args37(1).Name = "Collate"
args37(1).Value = true
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args37())
end sub _________________ Roeret
The fit deadhead |
|