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
|
Sub ChercheCouleur()
Dim c As Range
Dim cMemo As Range
Dim cFin As Range
Dim r As Range
Dim i As Integer
For i = 1 To ActiveDocument.Characters.Count + 1
Set c = ActiveDocument.Characters(i)
Debug.Print c
Select Case c.Font.Color
Case wdColorAutomatic, wdColorBlack
If Not (cMemo Is Nothing) Then
Debug.Print "Fin couleur " & c
Set cFin = c
Set r = ActiveDocument.Range(Start:=cMemo.Start, End:=cFin.End)
r.Text = "[" & r.Text & "]"
i = i + 2 'On passe les [ et ]
Set cMemo = Nothing
End If
Case Else
If cMemo Is Nothing Then
Debug.Print "Debut couleur " & c
Set cMemo = c
End If
End Select
Next
End Sub |
Partager