Sub AutoDeleteGray() Dim length As Integer Dim backPos As Integer p = Selection.Paragraphs.First Last = Selection.Paragraphs.First dd = Selection.Range.HighlightColorIndex Do While Selection.Characters.First.HighlightColorIndex = wdGray25 If (Selection.MoveRight <> 1) Then Exit Do Loop Do While Last = p length = 0 If (Selection.Characters.First.HighlightColorIndex = wdGray25) Then cursorStart = Selection.Start Do While Selection.Characters.First.HighlightColorIndex = wdGray25 length = length + 1 If Selection.MoveLeft(wdCharacter, 1) <> 1 Then Exit Do Loop If Selection.Characters.First.HighlightColorIndex <> wdGray25 And Selection.Characters.First.HighlightColorIndex <> wdUndefined Then Selection.MoveRight backPos = backPos - 1 length = length - 1 End If Selection.Start = cursorStart - length Selection.End = cursorStart + 1 Selection.Delete End If If (Selection.MoveLeft <> 1) Then Exit Do Last = Selection.Paragraphs.First backPos = backPos + 1 Loop Selection.Move Unit:=wdCharacter, Count:=backPos End Sub |
Références >