我需要找到特定的文本,比如小括号中的" PL",(),即
案文标准:
示例案文:
(目标价格:0.22欧元) Bank
VBA代码:
With Selection.Find
.Text = "\((.*?)\)" ' WhildCard
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Execute
End With
If Selection.Find.Found Then
'if found then need to select the paragraph and do something with it.
End If如果可以使用Wildcard,请帮助

发布于 2021-07-29 08:27:25
试试下面的代码:
Sub test1()
With ActiveDocument.Range.Find 'or Selection.Range.Find
.Text = "\(?*\)"
.MatchWildcards = True
Do While .Execute
If InStr(.Parent.Text, " PL") And .Parent.Font.Bold Then
'do something with it
.Parent.Paragraphs(1).Range.Delete
End If
Loop
End With
End Sub不带括号的Edit2模式
Sub test2()
Dim rng As Range
With ActiveDocument.Range.Find
.Text = " PL"
.MatchWildcards = True
Do While .Execute
If .Parent.Font.Bold Then
.Parent.Paragraphs(1).Range.Delete
End If
Loop
End With
End Subhttps://stackoverflow.com/questions/68572472
复制相似问题