Sub 取消文中高亮显示()
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = False
With Selection.Find
.Execute Replace:=wdReplaceAll, Forward:=True, _
Wrap:=wdFindContinue
End With
End Sub
Sub 空格高亮显示()
Dim rng As Range
Dim sFind As String
Dim i As Long
'设置要查找的内容为所有空格
sFind = " "
'将查找范围设置为整个文档
Set rng = ActiveDocument.Range
'在整个文档中查找并高亮显示空格
With rng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = sFind
.Replacement.Text = sFind
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
'循环遍历整个文档,直到找不到更多的空格
Do While .Execute
rng.HighlightColorIndex = wdYellow
Loop
End With
End Sub
Sub 空格删除()
Dim rng As Range
Set rng = ActiveDocument.Range
rng.Find.ClearFormatting
rng.Find.Replacement.ClearFormatting
rng.Find.Replacement.Text = "s"
rng.Find.Execute Replace:=wdReplaceAll
End Sub