|
楼主 |
发表于 2021-12-30 09:46
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
这个是查找的代码,先替换书名号内的,再查找,然后换回来。
- Sub 检测计量单位和简称() '不在书名号内查找,1个数组
- Application.ScreenUpdating = False
- ActiveDocument.Content.Font.ColorIndex = wdAuto
- Dim Keywd, n%
- Keywd = Array( "米", "平方", "立方", "公里", "吨", "千瓦","千伏")
- Options.DefaultHighlightColorIndex = wdYellow
- If ActiveDocument.TrackRevisions = True Then
- ActiveDocument.TrackRevisions = False
- ActiveDocument.ShowRevisions = False
- End If
- For i = 0 To UBound(Keywd)
- With ActiveDocument.Content.Find
- .ClearFormatting
- .Text = "《(*)" & Keywd(i) & "(*)》"
- .Replacement.Text = "《\1" & "№" & "\2》"
- .Format = False '不查找格式
- .MatchCase = True '区分大小写
- .MatchWholeWord = False '不采用全字匹配
- .MatchByte = True '区分全半角
- .MatchWildcards = True '不使用通配符
- .MatchSoundsLike = False '不查找同音
- .MatchAllWordForms = False '不查找单词的所有形式
- '.Replacement.Highlight = True
- .Forward = True
- .Execute Replace:=wdReplaceAll
- End With
- With ActiveDocument.Content.Find
- .ClearFormatting
- .Text = Keywd(i)
- .Format = False '不查找格式
- .MatchCase = True '区分大小写
- .MatchWholeWord = False '不采用全字匹配
- .MatchByte = True '区分全半角
- .MatchWildcards = False '不使用通配符
- .MatchSoundsLike = False '不查找同音
- .MatchAllWordForms = False '不查找单词的所有形式
- .Replacement.Highlight = True
- .Forward = True
- .Execute Replace:=wdReplaceAll
- Do While .Execute
- n = n + 1
- Loop
- End With
-
- With ActiveDocument.Content.Find
- .ClearFormatting
- .Text = "《(*)№(*)》"
- .Replacement.Text = "《\1" & Keywd(i) & "\2》"
- .Format = False '不查找格式
- .MatchCase = True '区分大小写
- .MatchWholeWord = False '不采用全字匹配
- .MatchByte = True '区分全半角
- .MatchWildcards = True '不使用通配符
- .MatchSoundsLike = False '不查找同音
- .MatchAllWordForms = False '不查找单词的所有形式
- '.Replacement.Highlight = True
- .Forward = True
- .Execute Replace:=wdReplaceAll
- End With
- Next
- Application.ScreenUpdating = True
- MsgBox "操作完成!!共找到有 " & n & "处错误。", vbOKOnly, "提示"
- End Sub
复制代码 |
|