Dave, Thanks for the help so far.
Your code works on it's own... but not when I put it into my nested mess.
Am I coding it correctly with the nexted With and loop statements?
Here's your recommended code with my abreviated loops shown...
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Product/DRD FAM"
.Replacement.Text = ""
.Forward = True
Do While .Execute
======'''insert your instructions here - abreviated logic====
V V V V V V V V V V V V V
V V
With Selection.Find' # 1
End With
Selection.Find.Execute
'This With / End With repeated 3 more times
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
^
======'''end of adding my abreviated logic====
Loop
End With
Here's my original code before adding your loops....
Sub FindPNsBackup()
Dim EWOPNs(500, 20) As String
eAction = 1 - 1
eYears = 2 - 1
eCurrentPart = 3 - 1
eNewPart = 4 - 1
eLF = 5 - 1
eFNADesc = 6 - 1
eVPPSDes = 7 - 1
eSide = 8 - 1
eMktDiv = 9 - 1
eColorCode = 10 - 1
eColorDesc = 11 - 1
eStk = 12 - 1
eServD = 13 - 1
eServI = 14 - 1
eNextUp = 15 - 1
eMakeFrom = 16 - 1
PNs = -1
'=============================================
'Finds info in first table of the part record.
'111111111111111111111111111111111111111111111
'=============================================
For x = 1 To 499
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Product/DRD FAM"
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Call MoveRightX(1)
If Trim(Selection.Text) = "Current Part" Then
PNs = PNs + 1
'True = Found Body of EWO.
Call MoveRightX(7)
EWOPNs(PNs, eAction) = Trim(Selection.Text)
Call MoveRightX(1)
EWOPNs(PNs, eYears) = Trim(Selection.Text)
Call MoveRightX(2)
EWOPNs(PNs, eCurrentPart) = Trim(Selection.Text)
Call MoveRightX(3)
EWOPNs(PNs, eNewPart) = Trim(Selection.Text)
End If
'=============================================
'Finds info in second table of the part record.
'222222222222222222222222222222222222222222222
'=============================================
Selection.Find.ClearFormatting
With Selection.Find
.Text = "UPC Prefix"
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
End With
Selection.Find.Execute
Call MoveRightX(3)
If Trim(Selection.Text) = "FNA Desc." Then
Call MoveRightX(2)
If Trim(Selection.Text) = "VPPS Description" Then
'Verified next section of EWO.
Call MoveRightX(4)
EWOPNs(PNs, eNextUp) = Trim(Selection.Text)
Call MoveRightX(1)
EWOPNs(PNs, eLF) = Trim(Selection.Text)
Call MoveRightX(4)
EWOPNs(PNs, eFNADesc) = Trim(Selection.Text)
Call MoveRightX(2)
EWOPNs(PNs, eVPPSDes) = Trim(Selection.Text)
End If
End If
'=============================================
'Finds info in third table of the part record.
'333333333333333333333333333333333333333333333
'=============================================
Selection.Find.ClearFormatting
With Selection.Find
.Text = "L/R"
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
End With
Selection.Find.Execute
Call MoveRightX(2)
If Trim(Selection.Text) = "Series" Then
Call MoveRightX(1)
If Trim(Selection.Text) = "Body (Styles)" Then
'Verified next section of EWO.
Call MoveRightX(6)
EWOPNs(PNs, eSide) = Trim(Selection.Text)
Call MoveRightX(1)
EWOPNs(PNs, eMktDiv) = Trim(Selection.Text)
End If
End If
'=============================================
'Finds info in forth table of the part record.
'444444444444444444444444444444444444444444444
'=============================================
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Engineer Code"
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
End With
Selection.Find.Execute
Call MoveRightX(8)
If Trim(Selection.Text) = "SERV Interchange" Then
'Verified next section of EWO.
Call MoveRightX(3)
EWOPNs(PNs, eColorCode) = Trim(Selection.Text)
Call MoveRightX(1)
EWOPNs(PNs, eColorDesc) = Trim(Selection.Text)
Call MoveRightX(1)
EWOPNs(PNs, eMakeFrom) = Trim(Selection.Text)
Call MoveRightX(2)
EWOPNs(PNs, eStk) = Trim(Selection.Text)
Call MoveRightX(1)
EWOPNs(PNs, eServD) = Trim(Selection.Text)
Call MoveRightX(1)
EWOPNs(PNs, eServI) = Trim(Selection.Text)
End If
Next x
End Sub