|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 duquancai 于 2017-10-27 20:18 编辑
Sub 你测试一下速度()
Dim mts As Object, reg As Object, n&, m&, Str$, doc As Document
Dim mhs As Object, x&, y&, p As Range, r As Range
Set doc = ActiveDocument
Set reg = CreateObject("vbscript.regexp")
reg.Global = True: reg.MultiLine = True
reg.Pattern = "^\s*\d+、(?:(?!^\s*\d+、).)+"
Set mts = reg.Execute(doc.Content.Text)
If Not mts Is Nothing Then
For j = mts.Count - 1 To 0 Step -1
m = mts(j).FirstIndex: n = mts(j).Length
Set p = doc.Range(m, m + n)
reg.Pattern = "^(.*)\r(?=.*^\1$)"
Set mhs = reg.Execute(p.Text)
If Not mhs Is Nothing Then
For i = mhs.Count - 1 To 0 Step -1
x = mhs(i).FirstIndex: y = mhs(i).Length
Set r = doc.Range(p.Start + x, p.Start + x + y)
r.Text = Empty
Next
End If
Next
End If
End Sub
|
|