Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-21-2017, 08:51 AM
sbye sbye is offline and if statement in word mailmerge Windows 10 and if statement in word mailmerge Office 2016
Novice
and if statement in word mailmerge
 
Join Date: Aug 2017
Posts: 9
sbye is on a distinguished road
Default and if statement in word mailmerge

Hi,
I am trying to get the mailmerge to look at a mailmerge field and if it displays the words "Continued" I want it to take no action, but if it does not display "Continued" and the page number is an even number I want it to insert a page break.

The code below inserts a blank page on every page unless it displays "Continued" which isn't quite correct.

{if {MERGEFIELD RunTotal \####,###,##0.00}="Continued" { IF{ =MOD({ PAGE \*Arabic },2)}=0 }"[page break]Intentionally blank page" " " }

Any help would be very much appreciated.



Thanks, Stephen.
Reply With Quote
  #2  
Old 08-21-2017, 02:54 PM
macropod's Avatar
macropod macropod is offline and if statement in word mailmerge Windows 7 64bit and if statement in word mailmerge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try a field coded as:
{IF{MERGEFIELD RunTotal}= "Continued" {IF{=MOD({PAGE},2)}= 0 "{QUOTE 12}Intentionally blank page"}}

Note: the displayed spaces are all required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 08-22-2017, 02:33 AM
sbye sbye is offline and if statement in word mailmerge Windows 10 and if statement in word mailmerge Office 2016
Novice
and if statement in word mailmerge
 
Join Date: Aug 2017
Posts: 9
sbye is on a distinguished road
Default

Hi Paul,
Thank you very much for your reply. Have entered the new code but still doesn't work. I've double checked spaces, brackets etc. are all correct but still no joy.

Thanks, Stephen.
Reply With Quote
  #4  
Old 08-22-2017, 02:39 AM
macropod's Avatar
macropod macropod is offline and if statement in word mailmerge Windows 7 64bit and if statement in word mailmerge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I suspect the underlying issue is that {MERGEFIELD RunTotal} never outputs "Continued", because the mailmerge process treats the entire column as numeric and anything text is output as 0. You should be able to test that. If I am correct about what's happening and if your data don't include and true 0s or blanks, you could re-code the field as:
{IF{MERGEFIELD RunTotal}= 0 {IF{=MOD({PAGE},2)}= 0 "{QUOTE 12}Intentionally blank page"}}
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 08-22-2017, 06:39 AM
sbye sbye is offline and if statement in word mailmerge Windows 10 and if statement in word mailmerge Office 2016
Novice
and if statement in word mailmerge
 
Join Date: Aug 2017
Posts: 9
sbye is on a distinguished road
Default

Hi Paul,
I have tested and it reads the "Continued" text fine.

The code below puts a blank page after every page where "Continued" is not displayed but I need this to only work on even numbered pages where "Continued" is not displayed.

Any ideas? I am new to Word if statements but I can feel a resolution is just around the corner!

{IF{MERGEFIELD RunTotal}<> "Continued" {IF{=MOD({PAGE},2)}= 0 " " "[page break]Intentionally blank page"}}
Reply With Quote
  #6  
Old 08-22-2017, 07:03 AM
macropod's Avatar
macropod macropod is offline and if statement in word mailmerge Windows 7 64bit and if statement in word mailmerge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The problem you're having is probably a result of the way the IF field gets evaluated. Try:
{={=MOD({PAGE},2) \# 0}+{IF{MERGEFIELD RunTotal}= "Continued" 0 1} \# ";;'{QUOTE 12}Intentionally blank page'"}
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 08-22-2017, 08:47 AM
sbye sbye is offline and if statement in word mailmerge Windows 10 and if statement in word mailmerge Office 2016
Novice
and if statement in word mailmerge
 
Join Date: Aug 2017
Posts: 9
sbye is on a distinguished road
Default

Hi Paul,
Tried this and it puts a blank page after every page, in other words every other page is blank regardless of whether "Continued" is on page or whether it is odd or even.

Thanks, Stephen.
Reply With Quote
  #8  
Old 08-22-2017, 03:06 PM
macropod's Avatar
macropod macropod is offline and if statement in word mailmerge Windows 7 64bit and if statement in word mailmerge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That suggests either:
• some of the braces you're using (i.e. { }) are not field braces. You can't type them or copy/paste them from here - they need to be created in pairs via Ctrl-F9, for example; or
• you've messed up the spaces and/or the use of single/double quotes in the field code. Note the use of single quotes for '{QUOTE 12}Intentionally blank page'.

PS: I've tested the field code, so I know it does work.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 08-23-2017, 02:42 AM
sbye sbye is offline and if statement in word mailmerge Windows 10 and if statement in word mailmerge Office 2016
Novice
and if statement in word mailmerge
 
Join Date: Aug 2017
Posts: 9
sbye is on a distinguished road
Default

Hi Paul,
I have attached a screenshot of my file. With this code in it puts a blank page after every page regardless of any conditions.

Sorry if I am being dense! I need it to do nothing on pages with "Continued" on and if a page does not have "Continued" on and it is even numbered then I need it to move it down i.e. from page number 2 to page number 3 by inserting a blank page on page 2.

Thanks for all your help so far Paul and it is encouraging it works for you.

Stephen.
Attached Images
File Type: png Capture.PNG (45.3 KB, 20 views)
Reply With Quote
  #10  
Old 08-23-2017, 04:26 AM
macropod's Avatar
macropod macropod is offline and if statement in word mailmerge Windows 7 64bit and if statement in word mailmerge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

A screen-shot isn't much good. I would need to see the actual document. That said, it appears you have a page break in the field code in addition to the one the {QUOTE 12} field would create.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 08-23-2017, 06:15 AM
sbye sbye is offline and if statement in word mailmerge Windows 10 and if statement in word mailmerge Office 2016
Novice
and if statement in word mailmerge
 
Join Date: Aug 2017
Posts: 9
sbye is on a distinguished road
Default

Hi Paul,
Please find attached file.

Thanks, Stephen.
Attached Files
File Type: doc oammstat4.doc (71.5 KB, 8 views)
Reply With Quote
  #12  
Old 08-23-2017, 02:14 PM
macropod's Avatar
macropod macropod is offline and if statement in word mailmerge Windows 7 64bit and if statement in word mailmerge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I stripped down your mailmerge main document to the basics and attached it to a data source with just the RunTotal field and an IF test that adds some extra lines in if the RunTotal field contains 'Continued' - so as to force the condition that would generate a second page. I then completed the merge and found the results to be expected. See attached.

Note: If you open the Output document and toggle Word's field code display 'on', that will cause the document to display a field like:
{={=MOD({PAGE},2) \# 0}+1 \# ";;'......Page Break......
Blank page'"}
with 'Blank page' on the second page, but that's only because you have Word's field code display toggled 'on'.
Attached Files
File Type: zip Demo.zip (150.0 KB, 17 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 08-24-2017, 02:40 AM
sbye sbye is offline and if statement in word mailmerge Windows 10 and if statement in word mailmerge Office 2016
Novice
and if statement in word mailmerge
 
Join Date: Aug 2017
Posts: 9
sbye is on a distinguished road
Default

Hi Paul,
Very sorry I know it will be me but I still can't get it to work, it doesn't seem to do anything. I have attached 2 files one with my code in and the other is a mailmerge example (it only contains demonstration data so there is nothing confidential in there).

For the mailmerge what I need to happen is:
Page 1 - take no action

Page 2 - because page 2 does not display "Continued" and it is an even page number it needs to insert a blank page here otherwise we would print off and send a statement to the first customer with the other customers information on the back page as they print duplex.

Page 3 - needs to display Abingtons details as this has been moved down from page 2.

Amazon customer - these 3 pages will be printed together and again with the same logic where it will start printing on an odd page and as there are 3 pages it will insert a blank page on 4th page so the next customer starts on a separate sheet of paper.

So it is only if there is a total on an even page number and the page above does not display "Continued" then it needs to insert a blank page.

Hope this makes sense and thanks for your patience.

Stephen.
Reply With Quote
  #14  
Old 08-24-2017, 06:54 AM
macropod's Avatar
macropod macropod is offline and if statement in word mailmerge Windows 7 64bit and if statement in word mailmerge Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

No attachments.

Do note that, in a letter mailmerge, each record is separated by a Section break, which results in the page numbering being reset to 1 for each record - the page #s don't increment in the same way they would in an ordinary document. If each record is only ever a single page, you could replace the {PAGE} field in the field code with a {SECTION} field. Alternatively, you should be able to configure the printer to insert a sheet feed between Sections (you may need to combine this with configuring the mailmerge main document to use a 'different first page' layout).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 08-24-2017, 09:12 AM
sbye sbye is offline and if statement in word mailmerge Windows 10 and if statement in word mailmerge Office 2016
Novice
and if statement in word mailmerge
 
Join Date: Aug 2017
Posts: 9
sbye is on a distinguished road
Default

Hi Paul,
Thank you. The best we have achieved is a new page for each customer except if "Continued" is on the page. Are you saying it cannot use the page numbers as they are reset for each record and each record may be 1 page or multiple pages?

Thanks, Stephen.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
and if statement in word mailmerge Microsoft Word IF statement issues micro44 Word 4 10-23-2014 12:10 PM
Help with IF statement in word 2010 Mad Word 2 04-06-2013 06:31 AM
and if statement in word mailmerge Mailmerge to Email with a mailmerge attachment Baldeagle Mail Merge 8 02-11-2013 04:40 AM
and if statement in word mailmerge Mailmerge to Email with a mailmerge attachment Baldeagle Mail Merge 13 05-29-2012 02:04 PM
and if statement in word mailmerge Word Mailmerge wont print aovc Mail Merge 1 05-06-2011 05:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft