Macro Excel en Basic OOo
Résolu
Jgotheboss
Messages postés
24
Date d'inscription
Statut
Membre
Dernière intervention
-
Jgotheboss Messages postés 24 Date d'inscription Statut Membre Dernière intervention -
Jgotheboss Messages postés 24 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je suis tout nouveau sur ce forum. j'ai passé ma journée à chercher des infos sur les macros sous Calc Openoffice mais je trouve pas ce que je cherche.
En fait j'aimerai passer complètement sous Openoffice et j'utilise chaque jour sous Excel une petite macro très simple:
Je supprime la colonne B
Je coupe la colonne D
J'insert la colonne coupée entre la G et la H.
Le code sous excel est:
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("D:D").Select
Selection.Cut
Columns("H:H").Select
Selection.Insert Shift:=xlToRight
Range("G7:I7").Select
Range("I7").Activate
J'ai essayer d'enregistrer la macro sous Calc, mais il applique tout ce que je lui demande à la colonne A, je sais pas comment changer ça...
Si vous pouviez m'aider de vous serez très reconnaissant.
Je suis tout nouveau sur ce forum. j'ai passé ma journée à chercher des infos sur les macros sous Calc Openoffice mais je trouve pas ce que je cherche.
En fait j'aimerai passer complètement sous Openoffice et j'utilise chaque jour sous Excel une petite macro très simple:
Je supprime la colonne B
Je coupe la colonne D
J'insert la colonne coupée entre la G et la H.
Le code sous excel est:
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("D:D").Select
Selection.Cut
Columns("H:H").Select
Selection.Insert Shift:=xlToRight
Range("G7:I7").Select
Range("I7").Activate
J'ai essayer d'enregistrer la macro sous Calc, mais il applique tout ce que je lui demande à la colonne A, je sais pas comment changer ça...
Si vous pouviez m'aider de vous serez très reconnaissant.
A voir également:
- Com.sun.star.beans.propertyvalue
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Liste déroulante excel - Guide
- Mise en forme conditionnelle excel - Guide
- Word et excel gratuit - Guide
- Microsoft 365 basic - Accueil - Microsoft Office
5 réponses
En m'inspirant de ce que m'a donné l'enregistreur automatique de macro, j'ai enfin réussi à la faire!
Il était surtout de question de donner un point de départ à mes actions avec des lignes du type:
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$D$20"
Là ça marche mais je suis sûr qu'il y a un paquet de lignes inutiles, mais c'est pas grâve! Merci encore Dave!
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 = "$D$20"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$D$20"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$D$20"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "ToPoint"
args4(0).Value = "$B$2:$B$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args4())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:Open", "", 0, Array())
rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "ToPoint"
args6(0).Value = "$B$2:$B$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "ToPoint"
args7(0).Value = "$B$1:$B$50"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args7())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Cut", "", 0, Array())
rem ----------------------------------------------------------------------
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = "Flags"
args9(0).Value = "A"
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, args9())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:DeleteColumns", "", 0, Array())
rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "ToPoint"
args11(0).Value = "$C$1:$C$50"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args11())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Cut", "", 0, Array())
rem ----------------------------------------------------------------------
dim args14(0) as new com.sun.star.beans.PropertyValue
args14(0).Name = "ToPoint"
args14(0).Value = "$G$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args14())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertColumns", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
rem ----------------------------------------------------------------------
dim args15(0) as new com.sun.star.beans.PropertyValue
args15(0).Name = "ToPoint"
args15(0).Value = "$C$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args15())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:DeleteColumns", "", 0, Array())
Il était surtout de question de donner un point de départ à mes actions avec des lignes du type:
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$D$20"
Là ça marche mais je suis sûr qu'il y a un paquet de lignes inutiles, mais c'est pas grâve! Merci encore Dave!
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 = "$D$20"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$D$20"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$D$20"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "ToPoint"
args4(0).Value = "$B$2:$B$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args4())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:Open", "", 0, Array())
rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "ToPoint"
args6(0).Value = "$B$2:$B$7"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "ToPoint"
args7(0).Value = "$B$1:$B$50"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args7())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Cut", "", 0, Array())
rem ----------------------------------------------------------------------
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = "Flags"
args9(0).Value = "A"
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, args9())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:DeleteColumns", "", 0, Array())
rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "ToPoint"
args11(0).Value = "$C$1:$C$50"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args11())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Cut", "", 0, Array())
rem ----------------------------------------------------------------------
dim args14(0) as new com.sun.star.beans.PropertyValue
args14(0).Name = "ToPoint"
args14(0).Value = "$G$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args14())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertColumns", "", 0, Array())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
rem ----------------------------------------------------------------------
dim args15(0) as new com.sun.star.beans.PropertyValue
args15(0).Name = "ToPoint"
args15(0).Value = "$C$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args15())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:DeleteColumns", "", 0, Array())
Suis pas un pro de OO et encore moins des Macro, mais j'ai déjà eu à chercher cela pour mes développeurs.
Regarde :
http://www.openoffice.org/documentation/HOW_TO/various_topics/VbaStarBasicXref.pdf
Il existe aussi une librairie : VbaStarBasicXref.sxw qui est supposé faire une partie de conversion automatique. Tu peux y jeter un coup d'oeil.
A+
Dave
Regarde :
http://www.openoffice.org/documentation/HOW_TO/various_topics/VbaStarBasicXref.pdf
Il existe aussi une librairie : VbaStarBasicXref.sxw qui est supposé faire une partie de conversion automatique. Tu peux y jeter un coup d'oeil.
A+
Dave
Merci Dave mais j'y comprends vraiment trop rien...
Enfin j'ai réussi à supprimer ma 2e colonne, mais alors je trouve rien sur les actions de copier/coller/couper des colonnes...
Enfin j'ai réussi à supprimer ma 2e colonne, mais alors je trouve rien sur les actions de copier/coller/couper des colonnes...
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question