Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2007

Tip: Looking for answers? Try searching our database.

Delete only "next page" section breaks and skip the "continous" section breaks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
andreas - 16 Jan 2007 11:58 GMT
I recently wrote a macro to delete all section breaks there are in any
document. It is a simple macro and running just fine.
Now, for certain reasons I would like to create a macro that deletes
only the "next page" section breaks, not the other ones, i.e. the
"continuous" section breaks. Can this be achieved somehow?

Help is appreciated. Thanks a lot in advance

Regards,

Andreas
Doug Robbins - Word MVP - 16 Jan 2007 13:16 GMT
This will convert them all to Continuous Section Breaks

Dim s As Section
For Each s In ActiveDocument.Sections
   If s.PageSetup.SectionStart = wdSectionNewPage Then
       s.PageSetup.SectionStart = wdSectionContinuous
   End If
Next s

Signature

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

>I recently wrote a macro to delete all section breaks there are in any
> document. It is a simple macro and running just fine.
[quoted text clipped - 7 lines]
>
> Andreas
andreas - 16 Jan 2007 15:58 GMT
Doug,

thanks for the quick answer. I guess, You may have misunderstood my
request. This macro should delete only the "new page" section breaks
and skip the continuous section breaks. Your colleague Greg Maxey
answered as well and his code is working well. Hence my question has
been answered. Nevertheless your code snippet serves me as well for
other macro routines. Thank you!

Doug Robbins - Word MVP schrieb:

> This will convert them all to Continuous Section Breaks
>
[quoted text clipped - 24 lines]
> >
> > Andreas
Doug Robbins - Word MVP - 16 Jan 2007 18:37 GMT
I figured that you could graft the code that you were using to delete the
sections into the If...then...Else statement.

Signature

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

> Doug,
>
[quoted text clipped - 35 lines]
>> >
>> > Andreas
andreas - 16 Jan 2007 20:27 GMT
Doug,

oops, you are right. I was a bit slow to catch on.

Best regards,

Andreas

Doug Robbins - Word MVP schrieb:

> I figured that you could graft the code that you were using to delete the
> sections into the If...then...Else statement.
[quoted text clipped - 46 lines]
> >> >
> >> > Andreas
Greg Maxey - 16 Jan 2007 14:10 GMT
Andreas,

This get very tricky due to the way sections work.  The following first
converts the break to a continuous section break and then deletes it.
It has not be extensively tested, but might suit your needs:

Sub Testing()
Dim oSection As Section
For Each oSection In ActiveDocument.Range.Sections
 Select Case oSection.PageSetup.SectionStart
   Case wdSectionNewPage
     oSection.PageSetup.SectionStart = wdSectionContinuous
     Dim oRng As Word.Range
     Set oRng = oSection.Range
     oRng.Collapse wdCollapseStart
     oRng.Move wdCharacter, -1
     oRng.Delete
   Case wdSectionOddPage, wdSectionEvenPage, wdSectionContinuous
     'Do Nothing
 End Select
Next
End Sub

> I recently wrote a macro to delete all section breaks there are in any
> document. It is a simple macro and running just fine.
[quoted text clipped - 7 lines]
>
> Andreas
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.