2013-06-27 30 views
0

我正在寫一個可以通過整個單詞查找特定文本並將其突出顯示的子文件。問題是用戶想要灰色文本(wdGrey25)而不是默認的黃色。下面是我的示例代碼:如何更改使用vba的單詞中的默認突出顯示?

Public Sub HighlightStrings() 

    Dim rng As Range 
    Set rng = ActiveDocument.Range(Start:=0, End:=0) 
    With rng.Find 
     .Forward = True 
     .Wrap = wdFindStop 
     .MatchWholeWord = True 

     .Text = "Claimant's name" 
     .Replacement.Highlight = True 
     .Execute Replace:=wdReplaceAll 

     .Text = "date" 
     .Replacement.Highlight = True 
     .Execute Replace:=wdReplaceAll 

     .Text = "he/she" 
     .Replacement.Highlight = True 
     .Execute Replace:=wdReplaceAll 

     .Text = "describe incident" 
     .Replacement.Highlight = True 
     .Execute Replace:=wdReplaceAll 

     .Text = "describe condition(s)" 
     .Replacement.Highlight = True 
     .Execute Replace:=wdReplaceAll 

     .Text = "describe occupational disease" 
     .Replacement.Highlight = True 
     .Execute Replace:=wdReplaceAll 

    End With 

End Sub 

到目前爲止,它完美地找到並沒有拋出對齊和定位關閉,與以前的版本的亮點,但高亮顏色是太痛苦了我們的老用戶可以關注一下。任何人都得到了解決辦法?

由於提前, -C§

回答

0

這是你在找什麼:

Options.DefaultHighlightColorIndex = wdGrey25 

你需要在你的代碼的開頭來設置。

相關問題