Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Mail Merge

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 09-08-2017, 06:32 PM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 331
jeffreybrown is on a distinguished road
Default Hide a certain date from the mergefield

I have a mergefield...

{ MERGEFIELD Anniv \@ "MMM d";}



...to show an anniversary date, but if the date equals 1/1/2016, I would like nothing to show in that field.

If there is a date other than 1/1/2016, how can I add text to the date?

Such as...

Anniversary: Nov 15
Reply With Quote
  #2  
Old 09-09-2017, 03:02 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,163
gmayor is a jewel in the roughgmayor is a jewel in the roughgmayor is a jewel in the roughgmayor is a jewel in the rough
Default

{ IF { MERGEFIELD Anniv \@ "MM/dd/yyyy" } <> "1/1/2016" "Anniversary: {MERGEFIELD Anniv \@ "MMM d" }" }
__________________
Graham Mayor - MS MVP (Word)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 09-09-2017, 05:44 AM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 331
jeffreybrown is on a distinguished road
Default

Hi Graham,

Thanks for the help, but the records with 1/1/2016 still show up.

I see where my initials error was, I wasn't comparing the date correctly, but is word comparing the date how it is formatted in the Excel document?

Also, with trying to understand the string you posted, where is the false side?

I found some code on-line which would allow you to post your current string as you did above without having to type it out, but it seemed old and did not work.

Do you know where such a code exists?
Reply With Quote
  #4  
Old 09-09-2017, 08:07 AM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 331
jeffreybrown is on a distinguished road
Default

Hi Graham,

Got it figured out...

I'd still be interested if you know or have some code which can help me post a mergefield string without the retyping or posting a picture.
Attached Images
File Type: gif Capture.GIF (7.5 KB, 4 views)
Reply With Quote
  #5  
Old 09-09-2017, 11:30 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,300
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

For macros to:
convert field codes to text strings on the clipboard, see: http://www.gmayor.com/export_field.htm#FieldToText
convert field text strings to field codes in a document, see: http://www.gmayor.com/export_field.htm#TextToField
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #6  
Old 09-10-2017, 01:09 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,163
gmayor is a jewel in the roughgmayor is a jewel in the roughgmayor is a jewel in the roughgmayor is a jewel in the rough
Default

Paul has covered the links to code to post field constructions.

As for the construction I posted (without access to your data to see what the field actually produced) it doesn't need the alternative. If the condition is not met, the field produces nothing. The idea being to compare what { MERGEFIELD Anniv } produces with the equivalent date in the same format.
__________________
Graham Mayor - MS MVP (Word)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #7  
Old 09-10-2017, 06:34 AM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 331
jeffreybrown is on a distinguished road
Default

Thanks Paul and Graham.

@Graham, I finally got the formats the same and it works as you posted. Thanks again.
Reply With Quote
Reply
Please reply to this thread with any new information or opinions.

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Hide/Un-hide a worksheet based on cell on another sheet. easton11 Excel Programming 1 06-02-2015 12:07 PM
Printing selected pages based on a MERGEFIELD.g. If MERGEFIELD=x then print pages 1,2,4 if MERGEFIEL Richard.p Word 3 04-21-2015 01:14 AM
SUM a single mergefield kawirider88 Mail Merge 1 09-29-2013 06:37 PM
Substituting a value using MERGEFIELD CharlieVW Mail Merge 3 05-07-2012 12:11 PM
Mergefield date error michielvanderbiest Word 1 04-12-2010 11:22 PM


All times are GMT -7. The time now is 07:01 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft