|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
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
|
|