|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
二位过年好!假期在论坛交流一下感觉也是不错的。
可试试如下代码的效果:
- Sub test1()
- Options.DefaultHighlightColorIndex = wdDarkBlue
- Application.ScreenUpdating = False
- With ActiveDocument.Content.Find
- With .Replacement.Font
- .Parent.Highlight = True
- .Name = "Arial Black"
- .NameFarEast = "方正粗黑宋简体"
- .Size = 10.5
- .ColorIndex = 7
- .Bold = 0
- End With
- .Execute "[!^13\]]@\|[!^13]{1,}", , , 1, , , , , , "^&", 2
- End With
- Application.ScreenUpdating = True
- End Sub
- Sub test2()
- Dim i As Integer
- Application.ScreenUpdating = False
- With ActiveDocument.Content.Find
- Do While .Execute("|") '只查找指定的字符
- With .Parent
- .Expand wdParagraph '此处也包含段落标记
- .SetRange .Start + InStr(.Text, "]"), .End - 1
- With .Font
- .Name = "Arial Black"
- .NameFarEast = "方正粗黑宋简体"
- .Size = 10.5
- .ColorIndex = 7
- .Bold = 0
- End With
- .HighlightColorIndex = wdDarkBlue
- .Collapse 0
- i = i + 1
- End With
- Loop
- End With
- Application.ScreenUpdating = True
- MsgBox "共找到" & i & "个匹配。"
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|