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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
Sub ModifierTableau(ByVal DocEnCours6 As Document, ByVal NumeroTable As Integer)
'Public MatriceColonne1() As Variant --> mis dans le Module 1_variablesPubliques
'Dim DocEnCours6 As Document --> déjà déclaré dans le titre de la sub
Dim MaTable As Table '--> est aussi en variable publique (mais si pas déclarée dans la macro, la macro s'arrête après "fractionner en 3 colonnes"
Dim I As Integer
On Error GoTo Fin
Erase MatriceColonne1
With DocEnCours6 'remplace : Set DocEnCours6 = ActiveDocument
If .Tables.Count > 3 Then
Set MaTable = .Tables(NumeroTable) 'remplace Set MaTable = .Tables(4)
ChargerLaMatriceColonne1 MaTable 'procédure décrite après celle-ci
Else
MsgBox "Le nombre de tables est de " & .Tables.Count, vbCritical
GoTo Fin
End If
FractionnerEn3Colonnes DocEnCours, 4 'procédure décrite après celle-ci
With MaTable
For I = 2 To .Rows.Count
With .Cell(I, 1).Range
.Text = MatriceColonne1(I - 1)
End With
.Cell(I, 2).Range.Text = ""
Next I
End With
End With
GoTo Fin
Fin:
Set MaTable = Nothing
Set DocEnCours = Nothing
End Sub
Sub ChargerLaMatriceColonne1(ByVal TableEnCours As Table)
Dim J As Integer
With TableEnCours
ReDim MatriceColonne1(.Rows.Count - 1)
For J = 1 To .Rows.Count
MatriceColonne1(J - 1) = .Cell(J, 1).Range.Text
Next J
End With
End Sub
Sub FractionnerEn3Colonnes(ByVal DocEnCours7 As Document, ByVal NumeroTable As Integer)
'Pour modifier les colonnes de la table 4
Dim L As Integer
With DocEnCours7
If .Tables.Count >= NumeroTable Then
Set MaTable = .Tables(NumeroTable)
With MaTable
.Columns(1).Cells.Split NumRows:=1, NumColumns:=3, MergeBeforeSplit:=False
.Cell(1, 2).Range.Text = "Rev. du document"
.Cell(1, 3).Range.Text = "Date"
End With
With MaTable.Cell(1, 2).Range.Font
.Bold = False
.Name = "Arial"
.Size = 7
End With
With MaTable.Cell(1, 3).Range.Font
.Bold = False
.Name = "Arial"
.Size = 7
End With
With MaTable
For L = 2 To MaTable.Rows.Count
.Cell(L, 1).Range.Font.Size = 11
Next
End With
Set MaTable = Nothing
End If
End With
End Sub
Sub CopieLargeursColonnesTableSource(ByVal DocSource2 As Document, ByVal NumeroTableSource As Integer, ByVal DocEnCours8 As Document, ByVal NumeroTableEnCours)
'Pour mettre les colonne de la table 4 aux mêmes dimensions que celles la table source
Dim C As Integer
Set TableSource = DocSource2.Tables(1)
With DocEnCours8
If .Tables.Count >= NumeroTableEnCours Then
Set MaTable = .Tables(NumeroTableEnCours)
With MaTable
For C = 1 To MaTable.Columns.Count
.Columns(C).Width = TableSource.Columns(C).Width
Next
'MaTable.Rows.Alignment = wdAlignRowCenter 'pour centrer le tableau horizontalement - deplacé dans FormaterToutesLesTables
End With
Set MaTable = Nothing
End If
End With
Set TableSource = Nothing
End Sub |
Partager