Dude a écrit :
Code : Tout sélectionner
dispatcher.executeDispatch(document, ".uno:DeleteCell", "", 0, args1())
Merci,
Petit Soucis: cette fonction est incompatible avec la sélection multiple (j'ai rien inventé, c’était le message d'erreur)
ça veut dire que je dois boucler colonne par colonne, et zone par zone, pour sélectionner les cellules vides pas à pas puis les supprimer.
De toute façon si je n'ai pas d'autre solution j'utiliserai bien ça, et voir sur un vrai fichier, combien ça va tourner.
Après un petit moment et surtout après m’être remise du "verrouillage" du fil, je re post :
Alors j'ai trouvé une alternative "de malade", qui ma cassé grave la tête, mais c'est quand même un truc de dingue de remplacer 3 ligne de VBA par ça :
Code : Tout sélectionner
sub SupprimeEtRemonte
dim odoc as object, osheets as object, cell as object
dim zonevide as variant, mazone as object, sh as object
dim oCursor as object, zoneSel as object, lign as object
dim zoneAdef as string
dim i as long, j as long, row as long
dim EndRow as long, EndCol as long
dim VIDE as boolean, NomDef as string
dim maCell as object, leszones as object
VIDE = true
row = 0
odoc = thiscomponent
osheets = odoc.Sheets
sh = oSheets.getByName("Feuille1")
oCursor = sh.createCursor()
oCursor.gotoEndOfUsedArea( False )
EndRow = oCursor.rangeAddress.EndRow
EndCol = oCursor.rangeAddress.EndColumn
for j = 0 to EndCol
for i = 0 to EndRow
Cell = sh.getCellByPosition(j, i)
if Cell.string <> "" and i = 0 then
VIDE = false
end if
if Cell.string = "" and VIDE = false then
VIDE = true
row = i
end if
if Cell.string <> "" and VIDE = true then
VIDE = false
odoc.currentController.select(sh.getCellRangeByPosition(j,row,j,i-1))
call DeleteCell
i = row
end if
next i
row = 0
next j
End sub
'--------------------------------------------------------------------------
'Macro pour la suppression d'une zone sélectionnée
'--------------------------------------------------------------------------
Sub DeleteCell
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Flags"
args1(0).Value = "U"
dispatcher.executeDispatch(document, ".uno:DeleteCell", "", 0, args1())
End Sub
Voilà, j'ai rien trouvé de mieux