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
|
Sub TestMajChamps()
MajChamps "Commune 2", "Motif 2", "Période 2"
End Sub
Sub MajChamps(ByVal CommuneChoisie As String, ByVal MotifChoisi As String, ByVal PeriodeChoisie As String)
Dim I As Integer, J As Integer
Dim MonRange As Range
With ActiveDocument
For J = 1 To .Shapes.Count
With .Shapes(J).TextFrame
If .HasText Then
If .TextRange.Fields.Count > 0 Then
For I = 1 To .TextRange.Fields.Count
With .TextRange.Fields(I)
If InStr(1, .Code, "commune", vbTextCompare) > 0 Then
Set MonRange = .Result
MonRange.Text = CommuneChoisie
.Result = MonRange
Set MonRange = Nothing
End If
If InStr(1, .Code, "motif", vbTextCompare) > 0 Then
Set MonRange = .Result
MonRange.Text = MotifChoisi
.Result = MonRange
Set MonRange = Nothing
End If
If InStr(1, .Code, "période", vbTextCompare) > 0 Then
Set MonRange = .Result
MonRange.Text = PeriodeChoisie
.Result = MonRange
Set MonRange = Nothing
End If
End With
Next I
End If
End If
End With
Next J
End With
End Sub |
Partager