Quote:
Originally Posted by flds
You will notice in Post # 20 and 26 I said that the document may contain more the 1 section that contains 'Design Requirements'
|
And, when I sought clarification, in terms of Word Section breaks (which is what I've used for everything else):
Quote:
Regarding the 'Design Requirements' portion of the document, when I refer to 'Section' I mean a Word Section defined via Section breaks - Word has no such thing as sub-sections. So, does the 'Design Requirements' portion of the document consist of one Section?
|
you replied with:
Quote:
Yes, it consist of one section.
|
So, to get the code to work with multiple consecutive 'Design Requirement' Sections, change the line:
Code:
Dim DocApp As Document, DocRef As Document, oShp As Shape, iShp As InlineShape
to:
Code:
Dim DocApp As Document, DocRef As Document, oShp As Shape, iShp As InlineShape, SubSctn As Section
and, replace:
Code:
If InStr(UCase(Sctn.Range.Sentences.First), "DESIGN REQUIREMENT") > 0 Then
Set Rng = Sctn.Range
'Cut the 'Design Requirement' Section from the
'source document and paste it into a new references document
Rng.Cut
with:
Code:
If InStr(UCase(Sctn.Range.Sentences.First), "DESIGN REQUIREMENT") > 0 Then
Set Rng = Sctn.Range
Rng.End = .Range.End
'Find the end of the last 'Design Requirements' Section
For Each SubSctn In Rng.Sections
If InStr(UCase(SubSctn.Range.Sentences.First), "DESIGN REQUIREMENT") = 0 Then
Rng.End = SubSctn.Range.Start - 1
Exit For
End If
Next
'Cut the 'Design Requirement' Sections from the
'source document and paste them into a a new design requirements document
Rng.Cut