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
|
Public MatriceContents() As Variant
Public IndexTab As Integer
Sub Export_Titre2()
'Créer le projet Word vba
Dim I As Integer, J As Integer
Dim MonTableau As Variant
With ActiveDocument
IndexTab = 0
For I = 1 To .TablesOfContents.Count
With .TablesOfContents(I).Range
For J = 1 To .Paragraphs.Count
If Len(.Paragraphs(J).Range) > 2 Then
'MonTableau = Split(.Paragraphs(J).Range, "." & Chr(9))
MonTableau = Split(.Paragraphs(J).Range, Chr(9))
ReDim Preserve MatriceContents(2, IndexTab)
MatriceContents(0, IndexTab) = I
MatriceContents(1, IndexTab) = MonTableau(0)
MatriceContents(2, IndexTab) = Mid(MonTableau(1), 1, Len(MonTableau(1)) - 2)
IndexTab = IndexTab + 1
End If
Next J
End With
Next I
End With
'For IndexTab = LBound(MatriceContents, 2) To UBound(MatriceContents, 2)
' Debug.Print "TM : " & MatriceContents(0, IndexTab) & ", titre : " & MatriceContents(2, IndexTab) & ", profondeur : " & MatriceContents(1, IndexTab)
' Next IndexTab
End Sub |
Partager