|
- Sub 查找_通用_ActiveDocument()
- '全文查找:不激活对象/不选定文字内容/查找后光标不动/速度极快
- With ActiveDocument.Content.Find
- .ClearFormatting
- .Text = "[0-9. ^s^t,,]{1,}元"
- .Forward = True
- .MatchWildcards = True
- Do While .Execute
- With .Parent
- ' .Select
- .Font.Color = wdColorRed
- ' .Start = .End
- End With
- Loop
- End With
- End Sub
- Sub 查找_通用_Selection()
- '全文查找:激活对象/选定文字内容/查找后光标移动/速度较快
- With Selection
- .HomeKey Unit:=wdStory
- With .Find
- .ClearFormatting
- .Text = "[0-9. ^s^t,,]{1,}元"
- .Forward = True
- .MatchWildcards = True
- Do While .Execute
- With .Parent
- .Font.Color = wdColorRed
- ' .Start = .End
- End With
- Loop
- End With
- End With
- End Sub
- Sub 查找_通用_Range()
- '选区查找:不激活对象/仅在选定区域内查找文字(未选则全选)/速度较快
- Dim r As Range, a As Range
- With Selection
- If .Type = wdSelectionIP Then .WholeStory
- Set r = .Range
- Set a = .Range
- End With
- With r.Find
- .ClearFormatting
- .Text = "[0-9. ^s^t,,]{1,}元"
- .Forward = True
- .MatchWildcards = True
- Do While .Execute
- With .Parent
- ' .Select
- .Font.Color = wdColorRed
- If .Information(12) Then .Start = .End Else .SetRange Start:=.End, End:=a.End
- ' .Select
- End With
- Loop
- End With
- End Sub
- Sub 查找_通用_取消加粗()
- '全文查找(微软官方代码)
- With ActiveDocument.Content.Find
- .ClearFormatting
- .Font.Bold = True
- With .Replacement
- .ClearFormatting
- .Font.Bold = False
- End With
- .Execute FindText:="", ReplaceWith:="", Format:=True, Replace:=wdReplaceAll
- End With
- End Sub
- Sub 查找替换()
- '全文查找 aa 全部替换为 bb(标准)
- ActiveDocument.Content.Find.Execute FindText:="aa", MatchWildcards:=True, ReplaceWith:="bb", Replace:=wdReplaceAll
- End Sub
- Sub 查找替换2()
- '全文查找 aa 全部替换为 bb(简写)-- 1 的作用和 MatchWildcards:=True(勾选使用通配符)相同
- ActiveDocument.Content.Find.Execute "aa", , , 1, , , , , , "bb", 2
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|