View Single Post
 
Old 03-23-2014, 07:41 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

The simplest approach would be to store the Section break type before deleting, then re-apply it afterwards. That way you don't need to concern yourself with what type it was or might have changed to. For example, supposing you wanted to delete Section 2:
Code:
Sub Demo()
Dim ScnBrk As Long, i As Long
i = 2
With ActiveDocument
  ScnBrk = .Sections(i - 1).PageSetup.SectionStart
  .Sections(i).Range.Delete
  .Sections(i).PageSetup.SectionStart = ScnBrk
End With
End Sub
With this code, it really doesn't matter whether the Section break was continuous, next page, first page or even page - it'll be restored to its prior state.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote