如何使用vba更改word中的默认高亮显示?
我正在写一个sub,它通过全字查找特定文本并突出显示。问题是用户希望文本为灰色(WDGRY25),而不是默认的黄色。以下是我的示例代码:如何使用vba更改word中的默认高亮显示?,vba,ms-word,highlighting,Vba,Ms Word,Highlighting,我正在写一个sub,它通过全字查找特定文本并突出显示。问题是用户希望文本为灰色(WDGRY25),而不是默认的黄色。以下是我的示例代码: Public Sub HighlightStrings() Dim rng As Range Set rng = ActiveDocument.Range(Start:=0, End:=0) With rng.Find .Forward = True .Wrap = wdFindStop
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§这就是您要寻找的:
Options.DefaultHighlightColorIndex = wdGrey25
您需要在代码开头设置它。这就是您要查找的内容:
Options.DefaultHighlightColorIndex = wdGrey25
您需要在代码的开头设置它