Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Hello all
Can anyone help me with a macro or something similar to insert a blank page at the end of each letter in a mail merge, if the page number of the last page in that letter (section) is odd? I have tried all kinds of stuff, but just can't get it working. A macro solution where you just run the code after the mail merge would be the best solution for my needs I think. Its all needed because we want to print duplex (double-sided) to save some paper. Hope someone can help me. /Jacob |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Did you try Insert Section Break New Right-Hand Page?
On Tuesday, March 17, 2015 at 5:38:48 AM UTC-4, wrote: Hello all Can anyone help me with a macro or something similar to insert a blank page at the end of each letter in a mail merge, if the page number of the last page in that letter (section) is odd? I have tried all kinds of stuff, but just can't get it working. A macro solution where you just run the code after the mail merge would be the best solution for my needs I think. Its all needed because we want to print duplex (double-sided) to save some paper. Hope someone can help me. /Jacob |
#3
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I don't know what type of section break you are thinking about, but I have made some progress, but with a slightly different approach:
This is the code used: Sub CheckSecLen() Dim iSec As Integer Dim oRng As Range Dim iValue As Integer With ActiveDocument ' go through each section (except for the last one) For iSec = 1 To .Sections.Count - 1 ' create a range object at the start of the section Set oRng = .Sections(iSec).Range oRng.Collapse wdCollapseStart ' insert a sectionpages field .Fields.Add Range:=oRng, Type:=wdFieldSectionPages ' divide the sectionpages field by 2 ' if it gives a zero as the remainder, then ' you have an even number of pages in the section, ' which is what you want with an odd section page break If (.Sections(iSec).Range.Fields(1).Result Mod 2) 0 Then ' if you have an odd number of pages, then insert ' a page break before the section's section break Set oRng = .Sections(iSec).Range With oRng .Collapse Direction:=wdCollapseEnd .MoveEnd unit:=wdCharacter, Count:=-1 .InsertBreak Type:=wdPageBreak .InsertBreak Type:=wdPageBreak End With End If ' remove the sectionpages field that was added .Sections(iSec).Range.Fields(1).Delete Next iSec End With End Sub If you notice, I had to put two wdPageBreak's in, to make it work for me. I have also inserted some code after the last End With command (which is not included in the code above) that finds the last page and then pressed the arrow back (delete like button above the Return), so that the last page that is strangely added at the end of the document is removed. Not the way I thought it should be done, but it seems to work. |
#4
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
On Tuesday, March 17, 2015 at 9:27:32 PM UTC, wrote:
I don't know what type of section break you are thinking about, but I have made some progress, but with a slightly different approach: This is the code used: Sub CheckSecLen() Dim iSec As Integer Dim oRng As Range Dim iValue As Integer With ActiveDocument ' go through each section (except for the last one) For iSec = 1 To .Sections.Count - 1 ' create a range object at the start of the section Set oRng = .Sections(iSec).Range oRng.Collapse wdCollapseStart ' insert a sectionpages field .Fields.Add Range:=oRng, Type:=wdFieldSectionPages ' divide the sectionpages field by 2 ' if it gives a zero as the remainder, then ' you have an even number of pages in the section, ' which is what you want with an odd section page break If (.Sections(iSec).Range.Fields(1).Result Mod 2) 0 Then ' if you have an odd number of pages, then insert ' a page break before the section's section break Set oRng = .Sections(iSec).Range With oRng .Collapse Direction:=wdCollapseEnd .MoveEnd unit:=wdCharacter, Count:=-1 .InsertBreak Type:=wdPageBreak .InsertBreak Type:=wdPageBreak End With End If ' remove the sectionpages field that was added .Sections(iSec).Range.Fields(1).Delete Next iSec End With End Sub If you notice, I had to put two wdPageBreak's in, to make it work for me. I have also inserted some code after the last End With command (which is not included in the code above) that finds the last page and then pressed the arrow back (delete like button above the Return), so that the last page that is strangely added at the end of the document is removed. Not the way I thought it should be done, but it seems to work. Hello: I am trying to do the same as Jacob with the exception that my document is an Adobe PDF (due to its size we spool it in PDF format). Can I get assistance adding a blank page if the last page of my letter is odd? Thank you in advance. |
#5
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
On Wednesday, March 20, 2019 at 5:01:27 AM UTC-4, Angie wrote:
Hello: I am trying to do the same as Jacob with the exception that my document is an Adobe PDF (due to its size we spool it in PDF format). Can I get assistance adding a blank page if the last page of my letter is odd? Thank you in advance. This is for questions about MSWord. To add a blank page to a pdf, open it in Acrobat and use the "Combine Files" tool to add in a file you made from a blank Word (or other) document. |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding section names + page number into TOC | Microsoft Word Help | |||
Section breaks add page number without adding a page | Page Layout | |||
Blank pages for no reason using page and section breaks | Microsoft Word Help | |||
page number on blank pages when using section break | Microsoft Word Help | |||
Page numbering sections with number of pages in that section | New Users |