不愧大侠,还有个问题和大侠讨教:
你的32楼代码,我在关键代码中删掉了一些“(”和“)”也能实现相同的效果,能解释一下吗:
以下红色的部分是我删掉的:
Sub W_移形换位()
Dim reg As Object, mt, mh, oDOC As Document
Set oDOC = ActiveDocument
With oDOC.Content.Find
.Execute "([\((])^32{1,}", , , 1, , , , , , "\1", 2
.Execute "^32{1,}([\))])", , , 1, , , , , , "\1", 2
.Execute "^32{1,}", , , 1, , , , , , "^32", 2
End With
Set reg = CreateObject("vbscript.regexp")
reg.Global = True: reg.Pattern = "[\((][^)\)]+[\))]"
For Each mt In reg.Execute(oDOC.Content)
m = mt.FirstIndex: n = mt.Length
With oDOC.Range(m, m + n)
reg.Pattern = " ": t = reg.Execute(.Text).Count + 1
.Start = .Start - t
.Find.Execute "([一-﨩]{" & t & "})([\((])(*)([\))])", , , 1, , , , , , "\3\2\1\4", 1
reg.Pattern = "[\((][^)\)]+[\))]"
For Each mh In reg.Execute(.Text)
f = mh.FirstIndex: l = mh.Length
With oDOC.Range(.Start + f, .Start + f + l)
.Start = .Start + 1: .End = .End - 1
.Font.Color = RGB(255, 255, 255)
End With
Next
End With
Next
End Sub |