#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
{ IF { MERGEFIELD Anniv \@ "MM/dd/yyyy" } <> "1/1/2016" "Anniversary: {MERGEFIELD Anniv \@ "MMM d" }" }
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
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? |
#4
|
|||
|
|||
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. |
#5
|
||||
|
||||
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 [Fmr MS MVP - Word] |
#6
|
||||
|
||||
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) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#7
|
|||
|
|||
Thanks Paul and Graham.
@Graham, I finally got the formats the same and it works as you posted. Thanks again. |
|
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 | Mail Merge | 1 | 04-12-2010 11:22 PM |