2016-08-30 124 views
0

下面的vba代碼從文檔文檔中刪除所有'文字高亮顏色',但我只想'粉紅色高亮'被刪除,而忽略其他高亮顏色。任何幫助,親愛的會員,將不勝感激。謝謝。文字高亮顯示顏色

Sub HighlightRemoveAllPink() 

    Selection.Find.ClearFormatting 
    Selection.Find.Highlight = wdColorPink 
    Selection.Find.Replacement.ClearFormatting 
    Selection.Find.Replacement.Highlight = 0 
    With Selection.Find 
     .text = "" 
     .Replacement.text = "" 
     .Forward = True 
     .Wrap = wdFindContinue 
     .Format = True 
     .MatchCase = False 
     .MatchWholeWord = False 
     .MatchKashida = False 
     .MatchDiacritics = False 
     .MatchAlefHamza = False 
     .MatchControl = False 
     .MatchByte = False 
     .MatchWildcards = False 
     .MatchSoundsLike = False 
     .MatchAllWordForms = False 
    End With 

    Selection.Find.Execute Replace:=wdReplaceAll 


End Sub 

回答

0

首先,Selection.Find.Highlight預計布爾值,因此:

Selection.Find.Highlight = True 

要刪除特定的顏色,我用這個代碼:

With Selection.Find 
    .Highlight = True 
    Do While (.Execute(Forward:=True) = True) = True 
    If Selection.Range.HighlightColorIndex = wdColorPink Then 
     Selection.Collapse direction:=wdCollapseEnd 
    End If 
    Loop 
End With 
+0

不工作。這是文字高亮顯示,而不是'字體顏色'。 – vicki

+0

對不起,編輯我的帖子 –

+0

感謝兄弟,但不能再次工作。你可以重新檢查你的結局,並把你的替換代碼放在我的內部,讓我。感謝你的幫助。謝謝。 – vicki