|
楼主 |
发表于 2021-12-22 20:41
来自手机
|
显示全部楼层
413191246se 发表于 2021-12-21 23:28
* 楼主,我没有现成的代码,临时研制的,水平较低,敬请见谅!请试用前备份好你的文档,以免造成不必要的损 ...
改动了几处,请指正
Sub aaaa_CheckBookSymbol()
'查找书名号
'绿色正常!红色/粉色不正常!
'全选-->突出显示:无颜色-->清除突出显示
ActiveDocument.Content.Font.ColorIndex = wdAuto
With Selection
.HomeKey 6
With .Find
.ClearFormatting
.Text = "《"
.Replacement.Text = ""
.Forward = True
.MatchWildcards = True
Do While .Execute
With .Parent
Do
.MoveEnd
If .Text Like "*" & vbCr Then goto100
Loop Until .Text Like "*[《》]"
If .Text Like "*《" Then
100 .MoveEnd 1, -1
.Range.HighlightColorIndex = wdRed
ElseIf .Text Like "*》" Then
.Range.HighlightColorIndex = wdBrightGreen
End If
.Start = .End
End With
Loop
End With
End With
'''反向查找
With Selection
.EndKey 6
With .Find
.ClearFormatting
.Text = "》"
.Replacement.Text = ""
.Forward = False
.MatchWildcards = True
Do While .Execute
With .Parent
If .Range.HighlightColorIndex = 0 Then
Do
.MoveStart 1, -1
If Text Like vbcr&"*" Then goto200
Loop Until .Text Like "[《》]*"
If .Text Like "》*" Then
200 .MoveStart
.Range.HighlightColorIndex = wdPink
End If
End If
.End = .Start
End With
Loop
End With
.HomeKey 6
End With
MsgBox "Complete!", 0 + 48
End Sub |
|