|
楼主 |
发表于 2021-12-30 16:10
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
改了一下,应该可以了,太谢谢了
- Sub a___FindReplace_SymbolOut()
- Dim r As Range, strFindText$, strReplaceText$
- strFindText = InputBox("", "请输入要<查找>的关键词!", "建议")
- If strFindText = "" Then Exit Sub
- strReplaceText = InputBox("", "请输入要<替换>的关键词!", "意见")
- If strReplaceText = "" Then Exit Sub
- With Selection
- .HomeKey 6
- With .Find
- .ClearFormatting
- .Text = strFindText
- .Replacement.Text = ""
- .Forward = True
- .MatchWildcards = True
- Do While .Execute
- With .Parent
- Set r = .Range
- Do
- .MoveStart 1, -1
- If .Text Like vbCr & "*" Then
- r.Select
- Exit Do
- End If
- Loop Until .Text Like "[((《》))]*"
- Do
- .MoveEnd
- If .Text Like "*" & vbCr Then
- r.Select
- Exit Do
- End If
- Loop Until .Text Like "*[((《》))]"
- If .Text Like "[((《]*[》))]" Then
- r.Select
- r.HighlightColorIndex = wdBrightGreen
- Else
- r.select '增加这一句
- .Text = strReplaceText
- .Font.Color = wdColorRed
- .Font.Underline = wdUnderlineDouble
- End If
- .Start = .End
- End With
- Loop
- End With
- End With
- End Sub
复制代码 |
|