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 56 57 58
|
Sub TransformerEnTableau()
Dim I As Integer
Dim Continuer As Boolean
With ActiveDocument
For I = .Paragraphs.Count To 1 Step -1
With .Paragraphs(I)
.Range.Select
Continuer = True
If Selection.Range.Tables.Count > 0 Then Continuer = False
If Continuer = True Then
If InStr(1, Selection.Range, "[tab1]", vbTextCompare) > 0 Then
Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=7, NumRows:=2, AutoFitBehavior:=wdAutoFitWindow
End If
If InStr(1, Selection.Range, "[tab2]", vbTextCompare) > 0 Then
Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=8, NumRows:=2, AutoFitBehavior:=wdAutoFitWindow
End If
End If
End With
Next I
For I = 1 To .Tables.Count
With .Tables(I)
.Range.Select
If InStr(1, .Range.Cells(1).Range.Text, "[tab1]", vbTextCompare) > 0 Then
.Range.Font.Size = 8
.Range.Font.Name = "Arial"
.AutoFitBehavior (wdAutoFitContent)
.Style = "Tableau Grille*4 - Accentuation*3" ' A adapter
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
End If
If InStr(1, .Range.Cells(1).Range.Text, "[tab2]", vbTextCompare) > 0 Then
.Range.Font.Size = 8
.Range.Font.Name = "Arial"
.AutoFitBehavior (wdAutoFitContent)
.Style = "Tableau Grille*4 - Accentuation*6" ' A adapter
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
End If
End With
Next I
End With
End Sub |
Partager