|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
用正则 写一个:- Sub main()
- Dim d As Object, re As Object, q As Range, k$, mh As Object, i&, t#
- Set re = CreateObject("vbscript.regexp")
- re.Global = True: re.Pattern = "[一-﨩]"
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- With ActiveDocument
- Set q = IIf(Selection.Type = wdSelectionIP, .Content, Selection.Range)
- If q = .Content Then
- k = MsgBox("要进行全文处理吗?", vbYesNoCancel + vbQuestion, "全文处理判断")
- If k <> vbYes Then Exit Sub
- End If
- t = Timer
- For Each mh In re.Execute(q.Text)
- i = mh.FirstIndex
- With .Range(i, i + 1)
- If d.Exists(.Text) Then .Font.ColorIndex = 6
- d(.Text) = vbNullString
- End With
- Next
- End With
- Application.ScreenUpdating = True
- MsgBox Timer - t
- End Sub
复制代码
|
|