See if a word is contained in a string

J

Jamarr Hill

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.
 
T

Tony Jollans

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top