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
| Sub coloration2()
Dim mesnoms(5, 2) 'nom et teinte associée
mesnoms(1, 1) = "titi"
mesnoms(2, 1) = "toto"
mesnoms(3, 1) = "tutu"
mesnoms(4, 1) = "tata"
mesnoms(5, 1) = "tete"
mesnoms(1, 2) = 16774097
mesnoms(2, 2) = 14876613
mesnoms(3, 2) = 16773119
mesnoms(4, 2) = 16765393
mesnoms(5, 2) = 15204351
Application.ScreenUpdating = False
Selection.Find.ClearFormatting
With Selection.Find
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
For i = 1 To UBound(mesnoms)
Selection.HomeKey Unit:=wdStory
.Text = mesnoms(i, 1)
While Selection.Find.Execute
Selection.Shading.BackgroundPatternColor = mesnoms(i, 2)
Wend
Next i
End With
Selection.HomeKey Unit:=wdStory
End Sub |
Partager