|
本帖最后由 duquancai 于 2017-5-15 22:25 编辑
Sub 例文demo()
' 针对纯文本
Dim mt, reg As Object, n&, m&, j&, a, b
sr$ = "[〇一二三四五六七八九十百千万亿]"
a = Array("^" & sr & "+、", "^[((]\s*" & sr & "+\s*[))]", "^\d+[、..]", "^[((]\s*\d+\s*[))]")
b = Array(6, 5, 2, 11)
Set reg = CreateObject("vbscript.regexp")
reg.Global = True: reg.MultiLine = True
For j = 0 To UBound(a)
reg.Pattern = a(j)
For Each mt In reg.Execute(ActiveDocument.Content)
m = mt.FirstIndex: n = mt.Length
With ActiveDocument.Range(m, m + n)
.Expand 4: .Font.ColorIndex = b(j)
End With
Next
Next
End Sub
|
|