#1
|
|||
|
|||
Delete a page after Section Break Next Page
Hello everyone,
Working closely with Word for almost a year as an editor, I've gotten used to the fact that it likes to pull pranks on you. And sometimes you have to conduct some crazy manipulations to do some simple things. I wonder if deleting a page after a Section Break Next Page is an example of that. I know that the page that follows is the result of the type of the Section Break, which in this case is "Next Page", so Word automatically adds a new page after it. I have to delete the Section Break Next Page first, but it controls to many formatting elements (the page has a different header and footer and page orientation), so deleting it results in losing all that formatting. Is it possible to delete the page after Section Break Next Page painlessly? I attached an example file just in case. (I use Word 2007) Thank you very much for your help. |
#2
|
|||
|
|||
Hi, Aston. As long as you don't intend to have any pages follow your landscape page, you can delete the next-page section break on it, i.e., your second section break. The trick is, you must first change the page orientation of page three to landscape.
Best, Ulodesk |
#3
|
|||
|
|||
Thanks for your reply, Ulodesk.
But it only solves half of the problem. As I mentioned (and as you can see in my example file attached), the page that needs to be deleted has a different header and footer. When you delete Section Break Next Page on the previous page, it "inherits" the footer and header of the deleted page. So before deleting the page I do not need, I have to change its orientation, then make sure my headers and footers are the same on both pages, and what if I also have a multiple column layout on the previous page, I have to set up the same layout on the to-be-deleted page as well. Because I know that all this formatting will be gone once I remove the Section Break. Don't you think it's just too much hustle for a page that's going to be deleted anyway? Regards, Aston |
#4
|
||||
|
||||
Hi Aston,
Before deleting the unwanted Section, you need to format it the same as the preceding Section, including header & footer content. If the unwanted page is created knowing its "a page that's going to be deleted anyway", why are you creating it in the first place?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Because I edit other people's documents as my job. And some documents are really screwed up. Sometimes they put section breaks on every page. I guess they mix them up with page breaks. Really annoying.
Last edited by Charles Kenyon; 10-26-2018 at 06:40 AM. |
#6
|
||||
|
||||
Hi Aston,
You could use a macro to expedite the process. Here's one to take care of the most common issues. To use it, simply select a range that spans however many Section breaks need to be deleted for the Sections you want to merge. For example, if you want to merge two consecutive Sections, simply select a range spanning the offending Section break. For three Sections, select a range spanning both offending Section breaks. Code:
Sub MergeSections() Application.ScreenUpdating = False Dim sPageHght As Single, sPageWdth As Single Dim sHeaderDist As Single, sFooterDist As Single Dim sTMargin As Single, sBMargin As Single Dim sLMargin As Single, sRMargin As Single Dim sGutter As Single, sGutterPos As Single Dim lPaperSize As Long, lGutterStyle As Long Dim lMirrorMargins As Long, lVerticalAlignment As Long Dim lScnStart As Long, lScnDir As Long Dim lOddEvenHdFt As Long, lDiffFirstHdFt As Long Dim bTwoPagesOnOne As Boolean, bBkFldPrnt As Boolean Dim bBkFldPrnShts As Boolean, bBkFldRevPrnt As Boolean Dim bOrientation As Boolean, oHdFt As HeaderFooter Dim Sctn1 As Section, Sctn2 As Section With Selection If .Sections.Count = 1 Then MsgBox "Selection does not span a Section break", vbExclamation Exit Sub End If Set Sctn1 = .Sections.First: Set Sctn2 = .Sections.Last With Sctn1.PageSetup lPaperSize = .PaperSize lGutterStyle = .GutterStyle bOrientation = .Orientation lMirrorMargins = .MirrorMargins lScnStart = .SectionStart lScnDir = .SectionDirection lOddEvenHdFt = .OddAndEvenPagesHeaderFooter lDiffFirstHdFt = .DifferentFirstPageHeaderFooter lVerticalAlignment = .VerticalAlignment sPageHght = .PageHeight sPageWdth = .PageWidth sTMargin = .TopMargin sBMargin = .BottomMargin sLMargin = .LeftMargin sRMargin = .RightMargin sGutter = .Gutter sGutterPos = .GutterPos sHeaderDist = .HeaderDistance sFooterDist = .FooterDistance bTwoPagesOnOne = .TwoPagesOnOne bBkFldPrnt = .BookFoldPrinting bBkFldPrnShts = .BookFoldPrintingSheets bBkFldRevPrnt = .BookFoldRevPrinting End With With Sctn2.PageSetup .GutterStyle = lGutterStyle .MirrorMargins = lMirrorMargins .SectionStart = lScnStart .SectionDirection = lScnDir .OddAndEvenPagesHeaderFooter = lOddEvenHdFt .DifferentFirstPageHeaderFooter = lDiffFirstHdFt .VerticalAlignment = lVerticalAlignment .PageHeight = sPageHght .PageWidth = sPageWdth .TopMargin = sTMargin .BottomMargin = sBMargin .LeftMargin = sLMargin .RightMargin = sRMargin .Gutter = sGutter .GutterPos = sGutterPos .HeaderDistance = sHeaderDist .FooterDistance = sFooterDist .TwoPagesOnOne = bTwoPagesOnOne .BookFoldPrinting = bBkFldPrnt .BookFoldPrintingSheets = bBkFldPrnShts .BookFoldRevPrinting = bBkFldRevPrnt .PaperSize = lPaperSize .Orientation = bOrientation End With With Sctn2 For Each oHdFt In .Footers oHdFt.LinkToPrevious = Sctn1.Footers(oHdFt.Index).LinkToPrevious If oHdFt.LinkToPrevious = False Then With oHdFt.Range .FormattedText = Sctn1.Footers(oHdFt.Index).Range.FormattedText Do While .Characters.Last.Previous = vbCr .Characters.Last.Previous.Delete If .Characters.Count = 1 Then Exit Do Loop End With End If Next For Each oHdFt In .Headers oHdFt.LinkToPrevious = Sctn1.Headers(oHdFt.Index).LinkToPrevious If oHdFt.LinkToPrevious = False Then With oHdFt.Range .FormattedText = Sctn1.Headers(oHdFt.Index).Range.FormattedText Do While .Characters.Last.Previous = vbCr .Characters.Last.Previous.Delete If .Characters.Count = 1 Then Exit Do Loop End With End If Next End With While .Sections.Count > 1 .Sections.First.Range.Characters.Last.Delete Wend End With Set Sctn1 = Nothing: Set Sctn2 = Nothing Application.ScreenUpdating = True End Sub For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Bookmarks in header
I know this is an old post. I stumbled across it looking for a solution with a random appearing error 4605 trying to set the linktoprevious property of a section.
Paul, your code works perfectly, thanks! In my situation I need to delete the whole last section. With some modifications this works well too. One thing though, because of the use of .formattedtext I lose bookmarks that are used in the header of first section. Any idea on how to fix that? |
#8
|
|||
|
|||
My mistake, it is not the formattedtext property, it is the deleting of the actual section break:
Code:
While .Sections.Count > 1 .Sections.First.Range.Characters.Last.Delete Wend 1. Create a document with two sections 2. First section with different first page, in header first page add two bookmarks 3. Add second section, only primary headers/footers, both empty 4. Select last paragraph first section, and first second section 5. Run the code 6. Bookmarks in first section are gone Is it possible to solve this? |
#9
|
||||
|
||||
The bookmarks are deleted because the content they were attached to gets deleted. The workaround requires something like (untested) -
Change: Code:
Dim Sctn1 As Section, Sctn2 As Section Code:
Dim Sctn1 As Section, Sctn2 As Section, BkMk As Bookmark, x As Long, y As Long Code:
.FormattedText = Sctn1.Footers(oHdFt.Index).Range.FormattedText Code:
For Each BkMk In Sctn1.Footers(oHdFt.Index).Range x = BkMk.Range.Start: y = BkMk.Range.End .Bookmarks.Add Name:=BkMk.Name, Range:=.SetRange(x, y) Next Code:
.FormattedText = Sctn1.Headers(oHdFt.Index).Range.FormattedText Code:
For Each BkMk In Sctn1.Headers(oHdFt.Index).Range x = BkMk.Range.Start: y = BkMk.Range.End .Bookmarks.Add Name:=BkMk.Name, Range:=.SetRange(x, y) Next
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
|||
|
|||
Thanks Paul,
Just what I came up with myself ;-) I created a subroutine that takes the two ranges as an argument and loops through all the bookmarks and recreates the bookmarks in the second range. Thanks again for your assistance! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
why the "section break-next page" is switched to "section break-continuous"? | Jamal NUMAN | Word | 6 | 12-14-2011 03:35 PM |
Page break - next page | Commodore | Word | 7 | 07-17-2011 12:09 AM |
Section Break Continuous: doesn't affect the format of the page numbering | Jamal NUMAN | Word | 2 | 06-22-2011 04:46 PM |
Page numbering starting on 2 after section break | pamm13 | Word | 1 | 06-22-2011 11:10 AM |
Anchoring a section break to the bottom of a page, and having a table pass over it??? | h3rk | Word Tables | 1 | 11-20-2009 07:34 AM |