Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

OR operator in Find and Replace

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
aussierugby@hotmail.com - 05 Feb 2006 21:59 GMT
I need to find a way, ANY way to find either "shall" or "require" in a
document at the same time using the "Find and Replace" object/tool.
I'm using VBA to tag each location, but the order is of great
importance.

Heck, I'd buy beers at this point. :)
Greg Maxey - 05 Feb 2006 22:05 GMT
To the best of my knowledge it can't be done as you would expect.
Another user and I where discussing using OR in a find text problem.  The
discussion turned to a very real human situation where the house is locked
and the car is locked.  A known spare house key is in the car and a known
spare car hey is in the house.  There are other keys somewhere to be found.
Obviously the problem is resolved and the search can end when either a house
or car key is found.

Sub HelmutsDilemma()
Dim aWord As Range
Dim myStr As String
For Each aWord In ActiveDocument.Range.Words
 myStr = aWord
 If InStrRev(myStr, " ") = Len(myStr) Then
   myStr = Left(myStr, (Len(myStr) - 1))
 End If
 Select Case myStr
   Case Is = "car", "house"
     If aWord.Next(Unit:=wdWord, Count:=1) = "keys " Or _
       aWord.Next(Unit:=wdWord, Count:=1) = "keys" Then
       With aWord
         .MoveEnd Unit:=wdWord, Count:=1
         .Select
       End With
       Exit Sub
     End If
   Case Else
     'Do Nothing
 End Select
Next
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> I need to find a way, ANY way to find either "shall" or "require" in a
> document at the same time using the "Find and Replace" object/tool.
> I'm using VBA to tag each location, but the order is of great
> importance.
>
> Heck, I'd buy beers at this point. :)
Helmut Weber - 05 Feb 2006 22:09 GMT
Hi N.N.,

http://groups.google.de/group/microsoft.public.word.vba.general/browse_frm/threa
d/c27b7d80e0a74811/48362c7e17c2373a?lnk=st&q=carkey+group%3Amicrosoft.public.wor
d.vba*+author%3AHelmuT+author%3AWeber&rnum=1&hl=de#48362c7e17c2373a


Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.