Hi flds,
Change:
SubSctn As Section
to:
i As Long
and replace everything between:
'Check for Design Requirements in the source document
and:
'String variable for the output filenames
with:
Code:
For Each Sctn In .Sections
If InStr(UCase(Sctn.Range.Sentences.First), "DESIGN REQUIREMENT") > 0 Then
Set Rng = Sctn.Range
'Delete anything after the first 'Design Requirements' Section that isn't
'also a 'Design Requirements' Section
Rng.End = .Range.End
For i = Rng.Sections.Count To 2 Step -1
If InStr(UCase(Rng.Sections(i).Range.Sentences.First), "DESIGN REQUIREMENT") = 0 Then _
Rng.Sections(i).Range.Delete
Next
'Cut the 'Design Requirement' Sections from the source document
'and paste them into a new design requirements document
Rng.Cut
Set DocDesReq = Documents.Add(Visible:=False)
'Process the new document
Call NewDoc(DocDesReq)
Exit For
End If
Next Sctn
Call Cleanup(.Range)