Discussion:
Section Break (Continuous)
(too old to reply)
Fuzzhead
2009-03-29 17:58:03 UTC
Permalink
I have documents with numerous Section Break (Continuous) in them that I want
to delete. How do I write a macro that only finds and deletes the Continuous
Section Breaks?
Doug Robbins - Word MVP on news.microsoft.com
2009-03-29 21:49:00 UTC
Permalink
Use:

Dim i As Long
Dim sb As Range
With ActiveDocument
For i = .Sections.Count To 2 Step -1
With .Sections(i)
If .PageSetup.SectionStart = wdSectionContinuous Then
.PageSetup.SectionStart = ActiveDocument.Sections(i -
1).PageSetup.SectionStart
Set sb = ActiveDocument.Sections(i - 1).Range
sb.End = sb.End - 1
sb.Collapse wdCollapseEnd
sb.Delete
End If
End With
Next i
End With
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Post by Fuzzhead
I have documents with numerous Section Break (Continuous) in them that I want
to delete. How do I write a macro that only finds and deletes the Continuous
Section Breaks?
Fuzzhead
2009-03-29 22:30:06 UTC
Permalink
Thank you Doug. That worked great.
Post by Doug Robbins - Word MVP on news.microsoft.com
Dim i As Long
Dim sb As Range
With ActiveDocument
For i = .Sections.Count To 2 Step -1
With .Sections(i)
If .PageSetup.SectionStart = wdSectionContinuous Then
.PageSetup.SectionStart = ActiveDocument.Sections(i -
1).PageSetup.SectionStart
Set sb = ActiveDocument.Sections(i - 1).Range
sb.End = sb.End - 1
sb.Collapse wdCollapseEnd
sb.Delete
End If
End With
Next i
End With
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Post by Fuzzhead
I have documents with numerous Section Break (Continuous) in them that I want
to delete. How do I write a macro that only finds and deletes the Continuous
Section Breaks?
t***@gmail.com
2014-07-10 12:53:25 UTC
Permalink
Hello, Doug

I would like for you to expand on that VBA code and tell me how I can edit it to search for all wdSectionContinuous breaks in a document and replace them with wdSectionNextPage? This is something I've been fighting with for months and this is the first page I have found that is remotely akin to it.
t***@gmail.com
2014-07-10 13:09:53 UTC
Permalink
I actually found the answer to my question. For anyone looking for a way to replace a certain type of section break with another type of section break, i.e, replace a Continuous Section Break with a Next Page Section Break, use the VBA code below:

Sub ReplaceSectionContinous()

Dim iSec As Integer
For iSec = ActiveDocument.Sections.Count To 2 Step -1
With ActiveDocument.Sections(iSec).Range.PageSetup
If .SectionStart = wdSectionContinuous Then
.SectionStart = wdSectionNewPage
End If
End With
Next iSec

End Sub

Loading...