Dear all

I try to search for certain text in a specified cell of a Word table, then fill the found text into another cell in this table by click a button. My code:

Dim acTable As Table
Dim mystring(0 To 2) As String
Dim r As Integer
Dim i As Integer
Dim msg As String
Dim rng As Range

Set acTable = ThisDocument.Tables(2)

r = acTable.Rows.Count

mystring(0) = "Pilot"
mystring(1) = "ATCo"
mystring(2) = "Aircraft"


Set rng = acTable.Cell(r, 2).Range


For i = 0 To 6

With rng.Find

.Text = mystring(i)
.Forward = True
.Wrap = wdFindStop
End With

rng.Find.Execute

If rng.Find.Found Then

msg = MsgBox("Add " & mystring(i), vbOKCancel)

If msg = vbOK Then

With acTable
.Cell(r, 4).Range.InsertAfter mystring(i)

End With
End If

End If

Next i


In the code, mystring(i) is predefined text which I want to find in a cell of Word table and fill them into other cells of this tabel.

So far, this code works ok if I only search once, or search one text or word in specified cell, however, some times, I need to search two different text or words in the cell, I have to set the Wrap property as

.Wrap=wdFindContinue

instead of .Wrap=wdFindStop

but this setting will search other part of the document as well, this is not what I want.

For example:

the cell content: The pilot requests pushback from the ATCo

the text I want to find from this content: pilot and ATCo

However, the text Aircraft is not in the cell but in other table of the Word document will be found, this is not what I want. I only want to search in a specified cell.

I appreciate any ideas and help