i

Fusion de texte réparti sur plusieurs cellules


Sub Fusion

       Dim oCell As Object

       Dim oPlage As Object

       Dim oTexte As string

       Dim c1 As Integer, c2 as Integer

       Dim lig As Integer, col As Integer


       ' Zone de fusion 

       lig = 5 ' lignes

       col = 8 ' colonnes

     

       ' les index partent de zéro

       lig = lig - 1

       col = col - 1

     

       For c1 = 0 To lig

          oTexte = ""

          For c2 = 0 To col

             oCell = ThisComponent.Sheets(0).GetCellByPosition(c2, c1)

             oTexte = oTexte & oCell.string    

             oCell.string = ""

          Next c2

          oCell = ThisComponent.Sheets(0).GetCellByPosition(0, c1)

          oCell.string = oTexte

          oPlage = ThisComponent.Sheets(0).getCellRangeByPosition( 0, c1, col, c1)

          oPlage.Merge( True )

       Next c1

    End Sub


macro_fusion.ods