Plouflechien
Messages postés2Date d'inscriptionjeudi 12 mars 2009StatutMembreDernière intervention14 octobre 2009
-
5 oct. 2009 à 21:19
Plouflechien
Messages postés2Date d'inscriptionjeudi 12 mars 2009StatutMembreDernière intervention14 octobre 2009
-
14 oct. 2009 à 13:22
Ami du soir bonsoir,
Alors voilà mon problème:
- J'ai créé une macro en basic qui a pour but de supprimer toute les cellules vides, hormis celle se trouvant entre 2 cellules pleines (En gros je ne supprime que les blocs de cellules vides de plus de 1 cellule).
Alors le truc c'est que ça marche, mais c'est super long. du coup je me demandai si quelqu'un arriverait à optimiser mon code;
Code :
' --------------------clean-------------------------------------------------- '
sub clean
' --------------------clean-------------------------------------------------- '
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
dim c as long
dim args1(0) as new com.sun.star.beans.PropertyValue
dim args2(1) as new com.sun.star.beans.PropertyValue
dim args3(1) as new com.sun.star.beans.PropertyValue
dim args4(1) as new com.sun.star.beans.PropertyValue
dim args5(1) as new com.sun.star.beans.PropertyValue
dim args6(0) as new com.sun.star.beans.PropertyValue
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
args1(0).Name = "ToPoint"
args1(0).Value = "$A$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
for c= 1 to 9000
If Thiscomponent.CurrentSelection.string = "" Then
args2(0).Name = "By"
args2(0).Value = 1
args2(1).Name = "Sel"
args2(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2())
Else
goto fin
End if
If Thiscomponent.CurrentSelection.string = "" Then
args3(0).Name = "By"
args3(0).Value = 1
args3(1).Name = "Sel"
args3(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args3())
args6(0).Name = "Flags"
args6(0).Value = "U"
dispatcher.executeDispatch(document, ".uno:DeleteCell", "", 0, args6())
goto fin2
Else
args5(0).Name = "By"
args5(0).Value = 2
args5(1).Name = "Sel"
args5(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args5())
End if
If Thiscomponent.CurrentSelection.string = "" Then
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2())
dispatcher.executeDispatch(document, ".uno:DeleteCell", "", 0, args6())
Else
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2())
End if
fin:
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2())
fin2:
next c
End Sub
Sympa non?
PS désolé pour la section VB6 mais y a pas de section basic...