View Single Post
 
Old 07-14-2011, 07:27 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,371
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by flds View Post
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
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote