Bonjour
Remarque préalable, ceci est une macro VBA Excel, il faudrait donc commencer ton module avec l’instruction :
Option VBASupport 1
Néanmoins, si cette instruction permet d’utiliser la syntaxe VBA, toutes les instructions ne sont pas fonctionnelles.
La programmation de macro avec LibreOffice peut être faite en mode “enregistrement”, mode simple pour les utilisateurs mais limité, ou via l’API, non limité mais supposant une connaissance de la programmation.
Ci-dessous un exemple de transposition de ta procédure qui mixe un peu des deux approches :
Sub Pys()
dim oSheet as object, document as object
dim dispatcher as object
dim args1(0) as new com.sun.star.beans.PropertyValue
dim args4(5) as new com.sun.star.beans.PropertyValue
dim lSelect(1) as long
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
args1(0).Name = "ToPoint"
args1(0).Value = "$Feuille1.$C$5:$G$5"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
oSheet = thiscomponent.sheets.getByName("Feuil2")
lSelect(0) = oSheet.rangeAddress.sheet
oSheet = thiscomponent.sheets.getByName("Feuil3")
lSelect(1) = oSheet.rangeAddress.sheet
args1(0).Name = "Tables"
args1(0).Value = lSelect()
dispatcher.executeDispatch(document, ".uno:SelectTables", "", 0, args1())
args1(0).Name = "ToPoint"
args1(0).Value = "$Feuil2.$B$4"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
args4(0).Name = "Flags"
args4(0).Value = "A"
args4(1).Name = "FormulaCommand"
args4(1).Value = 0
args4(2).Name = "SkipEmptyCells"
args4(2).Value = false
args4(3).Name = "Transpose"
args4(3).Value = true
args4(4).Name = "AsLink"
args4(4).Value = false
args4(5).Name = "MoveMode"
args4(5).Value = 4
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args4())
End sub
Voir SelectPlusieursFeuilles.ods
Cordialement