vba中的条件搜索
这是为了查找并突出显示Word文档中某些单词的实例。 在以下代码的TargetList中,如何插入这些单词: 1.“^$然而” 2.“但是” 3.“^分别为$ (我的意思是,条件搜索;例如,搜索“any letter”“space”“however”组合的实例。) 提前谢谢vba中的条件搜索,vba,search,conditional,highlight,Vba,Search,Conditional,Highlight,这是为了查找并突出显示Word文档中某些单词的实例。 在以下代码的TargetList中,如何插入这些单词: 1.“^$然而” 2.“但是” 3.“^分别为$ (我的意思是,条件搜索;例如,搜索“any letter”“space”“however”组合的实例。) 提前谢谢 Sub HighlightTargets2() Dim range As range Dim i As Long Dim TargetList TargetList = Array("asset and liabilit
Sub HighlightTargets2()
Dim range As range
Dim i As Long
Dim TargetList
TargetList = Array("asset and liability method", "auditor's", "Black Scholes", "comprised of", "comprised primarily of", "primarily comprised of", "defined benefit", "defined contribution", "effected", "effecting", "effective interest method", "effective interest rate method", "footnote", "high quality", "however ", "in the U.S.", "in the us", "kmpg", "kpgm", "kgpm", "lump sum", "manger", "more likely than not recognition", "more likely than not threshold", "multi-", "non-", "option-pricing", "payer", "percentage of completion method", "percentage of completion accounting", "polices", "post-", "pro-", "proforma", "re-", "related party transaction", "respectively ", "^# respectively", "respectfully", "revenues", "see note", "see footnote", "self insurance", "Self insured", "stop loss", "straight line basis", "straight line method", "the this", "the a", "third party transaction", "website", "-wide", " wide", "year end")
For i = 0 To UBound(TargetList)
Set range = ActiveDocument.range
With range.Find
.Text = TargetList(i)
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute(Forward:=True) = True
range.HighlightColorIndex = wdYellow
Loop
End With
Next
End Sub
我很确定你遗漏了一些信息,比如这是一个单词doc之类的。另外,这不是Vb.NET代码,可能是vba,但同样没有上下文;谢谢你,普洛托尼克斯,通知我这些重要的事情。我已相应地编辑了我的问题。