Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
[email protected] 04031987jj@gmail.com is offline
external usenet poster
 
Posts: 1
Default Adding a blank page if section has odd number of pages (mail merge)

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   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Adding a blank page if section has odd number of pages (mail merge)

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   Report Post  
Posted to microsoft.public.word.docmanagement
[email protected] blackeranddarker@gmail.com is offline
external usenet poster
 
Posts: 2
Default Adding a blank page if section has odd number of pages (mail merge)

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   Report Post  
Posted to microsoft.public.word.docmanagement
Angie Angie is offline
external usenet poster
 
Posts: 1
Default Adding a blank page if section has odd number of pages (mail merge)

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   Report Post  
Posted to microsoft.public.word.docmanagement
Peter T. Daniels Peter T. Daniels is offline
external usenet poster
 
Posts: 3,215
Default Adding a blank page if section has odd number of pages (mail merge)

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding section names + page number into TOC stickcc Microsoft Word Help 3 December 16th 08 12:13 AM
Section breaks add page number without adding a page rontiara Page Layout 3 January 26th 08 05:38 AM
Blank pages for no reason using page and section breaks Bruce Microsoft Word Help 1 September 19th 07 04:31 PM
page number on blank pages when using section break Howard Hayes Microsoft Word Help 2 October 31st 06 06:08 AM
Page numbering sections with number of pages in that section kjerome New Users 1 February 5th 06 01:36 PM


All times are GMT +1. The time now is 06:59 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"