Trésorier d'une petite association, j'ai construit un formulaire de saisies de données, avec principalement des listes déroulantes.
Les lignes s'incrémentent par la fonction - grande.valeur - et un compteur pour les numéros de pièces.
J'ai construit une macro pour copier tout cela dans un tableau, cela fonctionne partiellement.
Il me faut trouver les codes pour ne copier que les lignes non vide, a savoir un groupe de 4 lignes au maximum
Si H4 non vide copier la ligne A4:J4
Si H5 Non vide copier la ligne A5:J5
Il peut n'y avoir que 2 lignes dan ce groupe
De plus, comment copier/coller, toutes les lignes à la suite dans le tableau, toutes les lignes sont incrémentées.
Ci-joint la macro que j'ai construite :
Code : Tout sélectionner
sub EnregistrerSaisies
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 = 2
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$A$13:$K$13"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Flags"
args3(0).Value = "V"
dispatcher.executeDispatch(document, ".uno:InsertCell", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "ToPoint"
args4(0).Value = "$A$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args4())
rem ----------------------------------------------------------------------
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "ToPoint"
args5(0).Value = "$A$2:$J$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args5())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "ToPoint"
args7(0).Value = "$A$13:$J$13"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args7())
rem ----------------------------------------------------------------------
dim args8(5) as new com.sun.star.beans.PropertyValue
args8(0).Name = "Flags"
args8(0).Value = "SVDT"
args8(1).Name = "FormulaCommand"
args8(1).Value = 0
args8(2).Name = "SkipEmptyCells"
args8(2).Value = false
args8(3).Name = "Transpose"
args8(3).Value = false
args8(4).Name = "AsLink"
args8(4).Value = false
args8(5).Name = "MoveMode"
args8(5).Value = 4
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args8())
rem ----------------------------------------------------------------------
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = "ToPoint"
args9(0).Value = "$A$3:$J$3"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "ToPoint"
args10(0).Value = "$A$13:$J$13"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args10())
rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "Flags"
args11(0).Value = "V"
dispatcher.executeDispatch(document, ".uno:InsertCell", "", 0, args11())
rem ----------------------------------------------------------------------
dim args12(0) as new com.sun.star.beans.PropertyValue
args12(0).Name = "ToPoint"
args12(0).Value = "$A$3:$J$3"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args12())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args14(0) as new com.sun.star.beans.PropertyValue
args14(0).Name = "ToPoint"
args14(0).Value = "$A$13:$K$13"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args14())
rem ----------------------------------------------------------------------
dim args15(5) as new com.sun.star.beans.PropertyValue
args15(0).Name = "Flags"
args15(0).Value = "SVDT"
args15(1).Name = "FormulaCommand"
args15(1).Value = 0
args15(2).Name = "SkipEmptyCells"
args15(2).Value = false
args15(3).Name = "Transpose"
args15(3).Value = false
args15(4).Name = "AsLink"
args15(4).Value = false
args15(5).Name = "MoveMode"
args15(5).Value = 4
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args15())
rem ----------------------------------------------------------------------
dim args16(0) as new com.sun.star.beans.PropertyValue
args16(0).Name = "ToPoint"
args16(0).Value = "$B$13"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args16())
rem ----------------------------------------------------------------------
dim args17(0) as new com.sun.star.beans.PropertyValue
args17(0).Name = "ToPoint"
args17(0).Value = "$A$13:$K$13"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args17())
rem ----------------------------------------------------------------------
dim args18(0) as new com.sun.star.beans.PropertyValue
args18(0).Name = "Flags"
args18(0).Value = "V"
dispatcher.executeDispatch(document, ".uno:InsertCell", "", 0, args18())
rem ----------------------------------------------------------------------
dim args19(0) as new com.sun.star.beans.PropertyValue
args19(0).Name = "ToPoint"
args19(0).Value = "$A$4:$J$4"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args19())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args21(0) as new com.sun.star.beans.PropertyValue
args21(0).Name = "ToPoint"
args21(0).Value = "$A$13:$J$13"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args21())
rem ----------------------------------------------------------------------
dim args22(5) as new com.sun.star.beans.PropertyValue
args22(0).Name = "Flags"
args22(0).Value = "SVDT"
args22(1).Name = "FormulaCommand"
args22(1).Value = 0
args22(2).Name = "SkipEmptyCells"
args22(2).Value = false
args22(3).Name = "Transpose"
args22(3).Value = false
args22(4).Name = "AsLink"
args22(4).Value = false
args22(5).Name = "MoveMode"
args22(5).Value = 4
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args22())
rem ----------------------------------------------------------------------
dim args23(0) as new com.sun.star.beans.PropertyValue
args23(0).Name = "ToPoint"
args23(0).Value = "$A$13"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args23())
rem ----------------------------------------------------------------------
dim args24(0) as new com.sun.star.beans.PropertyValue
args24(0).Name = "ToPoint"
args24(0).Value = "$A$13:$K$13"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args24())
rem ----------------------------------------------------------------------
dim args25(0) as new com.sun.star.beans.PropertyValue
args25(0).Name = "Flags"
args25(0).Value = "V"
dispatcher.executeDispatch(document, ".uno:InsertCell", "", 0, args25())
rem ----------------------------------------------------------------------
dim args26(0) as new com.sun.star.beans.PropertyValue
args26(0).Name = "ToPoint"
args26(0).Value = "$A$5:$J$5"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args26())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args28(0) as new com.sun.star.beans.PropertyValue
args28(0).Name = "ToPoint"
args28(0).Value = "$A$13:$J$13"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args28())
rem ----------------------------------------------------------------------
dim args29(5) as new com.sun.star.beans.PropertyValue
args29(0).Name = "Flags"
args29(0).Value = "SVDT"
args29(1).Name = "FormulaCommand"
args29(1).Value = 0
args29(2).Name = "SkipEmptyCells"
args29(2).Value = false
args29(3).Name = "Transpose"
args29(3).Value = false
args29(4).Name = "AsLink"
args29(4).Value = false
args29(5).Name = "MoveMode"
args29(5).Value = 4
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args29())
rem ----------------------------------------------------------------------
dim args30(0) as new com.sun.star.beans.PropertyValue
args30(0).Name = "ToPoint"
args30(0).Value = "$A$12:$K$484"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args30())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:SortAscending", "", 0, Array())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:DataSort", "", 0, Array())
rem ----------------------------------------------------------------------
dim args33(9) as new com.sun.star.beans.PropertyValue
args33(0).Name = "ByRows"
args33(0).Value = true
args33(1).Name = "HasHeader"
args33(1).Value = false
args33(2).Name = "CaseSensitive"
args33(2).Value = false
args33(3).Name = "NaturalSort"
args33(3).Value = false
args33(4).Name = "IncludeAttribs"
args33(4).Value = true
args33(5).Name = "UserDefIndex"
args33(5).Value = 0
args33(6).Name = "Col1"
args33(6).Value = 1
args33(7).Name = "Ascending1"
args33(7).Value = true
args33(8).Name = "IncludeComments"
args33(8).Value = false
args33(9).Name = "IncludeImages"
args33(9).Value = true
dispatcher.executeDispatch(document, ".uno:DataSort", "", 0, args33())
rem ----------------------------------------------------------------------
dim args34(0) as new com.sun.star.beans.PropertyValue
args34(0).Name = "Nr"
args34(0).Value = 1
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args34())
rem ----------------------------------------------------------------------
dim args35(0) as new com.sun.star.beans.PropertyValue
args35(0).Name = "ToPoint"
args35(0).Value = "$C$5"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args35())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args37(0) as new com.sun.star.beans.PropertyValue
args37(0).Name = "ToPoint"
args37(0).Value = "$C$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args37())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args39(0) as new com.sun.star.beans.PropertyValue
args39(0).Name = "ToPoint"
args39(0).Value = "$C$9"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args39())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args41(0) as new com.sun.star.beans.PropertyValue
args41(0).Name = "ToPoint"
args41(0).Value = "$C$10"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args41())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args43(0) as new com.sun.star.beans.PropertyValue
args43(0).Name = "ToPoint"
args43(0).Value = "$C$12"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 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 = "$C$14"
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 = "$C$15"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args47())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args49(0) as new com.sun.star.beans.PropertyValue
args49(0).Name = "ToPoint"
args49(0).Value = "$C$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args49())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args51(0) as new com.sun.star.beans.PropertyValue
args51(0).Name = "ToPoint"
args51(0).Value = "$C$21"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args51())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args53(0) as new com.sun.star.beans.PropertyValue
args53(0).Name = "ToPoint"
args53(0).Value = "$C$22"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args53())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args55(0) as new com.sun.star.beans.PropertyValue
args55(0).Name = "ToPoint"
args55(0).Value = "$C$23"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args55())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args57(0) as new com.sun.star.beans.PropertyValue
args57(0).Name = "ToPoint"
args57(0).Value = "$D$21"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args57())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args59(0) as new com.sun.star.beans.PropertyValue
args59(0).Name = "ToPoint"
args59(0).Value = "$D$22"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args59())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args61(0) as new com.sun.star.beans.PropertyValue
args61(0).Name = "ToPoint"
args61(0).Value = "$D$23"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args61())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem ----------------------------------------------------------------------
dim args63(0) as new com.sun.star.beans.PropertyValue
args63(0).Name = "ToPoint"
args63(0).Value = "$I$4"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args63())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:SaveAll", "", 0, Array())
end sub