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 / March 2008

Tip: Looking for answers? Try searching our database.

See if a word is contained in a string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jamarr Hill - 06 Mar 2008 16:52 GMT
I am attempting to create a macro that will take an array and check to see if
a string located in the array is in a block of text.

So if I have
Dim ATCodes(2,2)

ATCodes(1,1) = "R"
ATCodes(1,2) = "Remove and Replace"
ATCodes(2,1) = "S"
ATCodes(2,2) = "Re-installed"

and I want to check if the ATCodes(n,2) is located in a block of text that
is after "CORR ACTION:" but before
"........................................", any help would be extremely
appreciated.
Tony Jollans - 06 Mar 2008 17:22 GMT
You probably want to do a bit more than this but maybe it will get you
started ...

   Set r = ActiveDocument.Content
   r.Find.Execute "CORR ACTION*........................................", _
                           MatchWildcards:=True
   For n = 1 To 2
       If InStr(r.Text, ATCodes(n, 2)) Then
           MsgBox "Found " & ATCodes(n, 2)
       End If
   Next

This first of all finds the block of text and then walks the list checking
each in turn for presence.

Signature

Enjoy,
Tony

>I am attempting to create a macro that will take an array and check to see
>if
[quoted text clipped - 12 lines]
> "........................................", any help would be extremely
> appreciated.

Rate this thread:






 
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.