|
楼主 |
发表于 2019-12-2 12:42
|
显示全部楼层
经过月余的学习,将代码改进,现在只需要1.3秒就可以完成。
- Sub 选择题秒填答案()
- Dim arr, mh, rng As Range, n As Long, i%, t
- t = Timer
- Set rng = ActiveDocument.Range
- rng.Find.Execute2007 FindText:="( )", ReplaceWith:="( )", Replace:=wdReplaceAll
- With CreateObject("vbscript.regexp")
- .Global = True
- .Pattern = "(\d+)\.([A-Ea-e])(?=\W)"
- Set arr = .Execute(rng)
- ' .Pattern = "\(\u00A0{6}\)"
- .Pattern = "\(\s{3}\)"
- For Each mh In .Execute(rng)
- n = mh.FirstIndex - 10
- ActiveDocument.Range(n, n + 1) = arr(i).submatches(1)
- i = i + 1
- Next
- End With
- MsgBox Timer - t
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|