|
本帖最后由 kqbt 于 2011-10-14 12:51 编辑
tan_mw 发表于 2011-10-14 11:21
无论上下联,相同字a的用一种颜色显示(如红色),相同字b的用另一颜色显示(如绿色),相同字c的用其他颜 ...
请测试如下代码:
- Sub FinReP()
- Dim iRng As Range, jRng As Range
- Dim i As Integer, j As Integer, o As Integer
- Set iRng = ActiveDocument.Content
- With iRng.Find
- .ClearFormatting
- .Replacement.ClearFormatting
- Do While .Execute(findtext:="<[!^13]@^13<[!^13]@^13", MatchWildcards:=True)
- Set jRng = iRng.Duplicate
- i = 1
- For j = 0 To Len(iRng) - 1
- Set jRng = Range(iRng.Start + j, iRng.Start + j + 1)
- If jRng Like "[一-﨩]" And jRng.Font.Color = wdColorAutomatic Then
- Set fRng = Range(jRng.End, iRng.End)
- o = 0
- Do While fRng.Find.Execute(findtext:=jRng, MatchWildcards:=False)
- i = i + 1
- jRng.Font.ColorIndex = i - o
- fRng.Font.ColorIndex = i - o
- fRng.SetRange fRng.End, iRng.End
- o = o + 1
- Loop
- End If
- Next
- iRng.SetRange iRng.End, ActiveDocument.Content.End
- Loop
- End With
- End Sub
复制代码
|
|