|
楼主 |
发表于 2017-3-19 08:41
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
我将自己5楼的代码简化一下,代码如下有问题,请大虾指瑕。
Sub 转中间汉字为黑色2()
Dim regx As Object, mth
sstr = ")("
Set regx = CreateObject("vbscript.regexp")
regx.Global = True
regx.Pattern = "\)[一-﨩]+\("
For Each mth In regx.Execute(ActiveDocument.Content)
k = mth.FirstIndex: c = mth.Length
With ActiveDocument.Range(k, k + c)
.Font.Name = "楷体" '"楷体"
.Start = .Start + 1
.End = .End - 1
.Font.ColorIndex = 1 '1,黑色;2,蓝色;3,天兰;4,绿色;5,红色;6,红色;7,黄色;8,白色
End With
For Each cha In ActiveDocument.Range(k, k + c).Characters
If InStr(sstr, cha) <> 0 Then
With cha.Font
.Font = "方正姚体"
.ColorIndex = 2
End With
End If
Next
' With ActiveDocument.Range(k, k + c).Characters(1)
' .Font.Name = "方正姚体"
' .Font.ColorIndex = 2
' End With
' With ActiveDocument.Range(k, k + c).Characters(c)
' .Font.Name = "方正姚体"
' .Font.ColorIndex = 2
' End With
Next
End Sub |
|