|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub test()
Dim i&, rngContent As Range, aMatch As Object, Rng As Range, m&, n&
Set rngContent = ActiveDocument.Content
With CreateObject("VBScript.RegExp")
.Pattern = "[\((【\[].+?[\))】\]]"
.Global = True
For Each aMatch In .Execute(rngContent.Text)
m = aMatch.FirstIndex: n = aMatch.Length
Set Rng = ActiveDocument.Range(rngContent.Start + m + 1, rngContent.Start + m + n - 1)
With Rng
.Font.Color = wdColorWhite
End With
Next
End With
Beep
End Sub
|
|