View Single Post
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Logical OR in Word wildcard searches

As previously posted there isn't really a method of using OR in Word Find
and Replace routines. You can use a bit of VBA brute force to the same
effect:

Sub HelmutsDilemma()
Dim aWord As Range
Dim pLast As String
For Each aWord In ActiveDocument.Range.Words
If aWord.Characters.Last = " " Then
pLast = " "
Else
pLast = ""
End If
Select Case Trim(aWord.Text)
Case Is = "headache", "migraine"
aWord = "sore head" & pLast
Case Else
'Do Nothing
End Select
Next
End Sub


wildetudor wrote:
Hey everyone,

I'm in a situation where I need to search for text in my document
with words that have several possible alternatives - and for that I
need to use a logical OR between them. If I'd used a Google search
syntax for example, it would have been easy - e.g. "having a headache
OR migraine", but in Word I don't know how to do it, and could not
find anything about this in the Word Help.

Can anyone advise me how to do this? Anticipated thanks!


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org