1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
Option Explicit
Public MatriceStyle() As Variant
Sub LancerChargerLaMatriceNumerotation()
Dim I As Integer
Erase MatriceStyle
ChargerLaMatriceNumerotation ActiveDocument, "Numérotation"
For I = LBound(MatriceStyle, 2) To UBound(MatriceStyle, 2)
Debug.Print "Paragraphe : " & MatriceStyle(0, I) & ", texte : " & MatriceStyle(1, I) & ", nouveau contenu : " & MatriceStyle(2, I)
Next I
End Sub
Sub ChargerLaMatriceNumerotation(ByVal DocEnCours As Document, ByVal StyleChoisi As String)
Dim IndexParagraphe As Integer, IndexMatrice As Integer
Dim MaChaineNumerotee As Variant
Dim ContenuParagraphe As String
With DocEnCours
IndexMatrice = 0
For IndexParagraphe = 1 To .Paragraphs.Count
With .Paragraphs(IndexParagraphe)
ContenuParagraphe = Mid(.Range.Text, 1, Len(.Range.Text) - 1)
If .Style = StyleChoisi And ContenuParagraphe <> "" Then
ReDim Preserve MatriceStyle(2, IndexMatrice)
MatriceStyle(0, IndexMatrice) = IndexParagraphe
MaChaineNumerotee = Split(ContenuParagraphe, "-")
If UBound(MaChaineNumerotee) > 0 Then
MatriceStyle(1, IndexMatrice) = Trim(MaChaineNumerotee(1))
Else
MatriceStyle(1, IndexMatrice) = ContenuParagraphe
End If
' Nouveau contenu de la ligne
MatriceStyle(2, IndexMatrice) = IndexMatrice + 1 & " - " & MatriceStyle(1, IndexMatrice)
IndexMatrice = IndexMatrice + 1
End If
End With
Next IndexParagraphe
End With
End Sub |
Partager