#1
|
|||
|
|||
Could anyone fix the attached if statement. thx
I have attached word doc with if statement that I can't get right. Could anyone please troublrshoot.
|
#2
|
||||
|
||||
You could use either:
{QUOTE"{SET Months {MERGEFIELD Loanmonths}}{=INT(Months/12) \# "0' year(s)'"} and {=MOD(Months,12) \# "0' month(s)'"}"} for an output like: # year(s) and # month(s) or, somewhat more sophisticated: {QUOTE"{SET Months {MERGEFIELD Loanmonths}}{=INT(Months/12)-1 \# "{=INT(Months/12) \# "0' years'"};;'1 year'"}{=(Months-INT(Months/12)*12)*(Months>12) \# "' and ';;"}{=MOD(Months,12)-1 \# "{=MOD(Months,12) \# "0' months'"};;'1 month'"}"}"} for an output like: 1 month 2 months 1 year 2 years 1 year and 1 month 1 year and 2 months 2 years and 1 month 2 years and 2 months For a macro to convert the above field code text representations to working field codes, See Convert Text Representations of Fields to Working Fields in the Mailmerge Tips and Tricks sticky thread (https://www.msofficeforums.com/mail-...ps-tricks.html) at the top of this forum.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
stuck on specific syntax for if statement in mergefield
Thanks for all the references. I need to know how to include the text "year(s)". Despite hours of searching through all references cannot find this specific syntax, and I have exhausted all ideas for guessing.
If you know this specific syntax, it would help me move on.... Thanks.. Does sticky code refer to the code in the mailmerge document? That is the only code I know. |
#4
|
||||
|
||||
I already gave you that in the first example in my previous post:
{=INT(Months/12) \# "0' year(s)'"} as part of the overall field or, if you prefer to have it as a stand-alone field: {=INT({MERGEFIELD LoanMonths}/12) \# "0' year(s)'"} or, to suppress the output for 0 years: {=INT({MERGEFIELD LoanMonths}/12) \# "0' year(s)';;"} Note that you can't use the \f switch in this context, as it applies only to the mergefield, not to any calculation based on it.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Using your exact syntax adn still getting error on loan months
Hi Paul,
I have used your first example exactly, also tried with curly brackets and I still get syntax error on loanmonths. |
#6
|
||||
|
||||
The field code in your attachment isn't anything like the ones in my post.
Attached is your document with some demonstration fields (select & press F9 to use) and mergefields based on them. I've slightly simplified the field construction.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Hi Paul,
Thanks for all the help. Could you look at this more finished version, and see why the If Statement itself is not working. |
#8
|
||||
|
||||
Try the attached. The field code is much simpler than what you're trying to do (and not an IF test in sight)!
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
That works perfectly. Thank-you for your help. I am at the end of a major project. It was a piece that needed to be done. I have never used Quote and Set before, so I will try to properly understand how and where to use it.
|
#10
|
||||
|
||||
The QUOTE field simply encompasses the remainder, making them easier to manage as a group and, more importantly in the mailmerge context, unlinks the others during the merge so you end up with only the results, not an active field.
The SET field creates a bookmark, named 'Loan' in the latest iteration, enabling that bookmark to be used in the main expression rather than having to repeat the MERGEFIELD for each component. Far less transparent, however, is the main expression's construction. What I've done is to take advantage of the fact a numeric picture switch takes three parameters: - +ve;-ve;0 and I've leveraged those to hold secondary field expressions and text. In fact, I've even nested a tertiary set of fields inside the secondary field's numeric picture switch. This kind of thing isn't anything you're likely to find documented anywhere other than in my Microsoft Word Field Maths Tutorial, available at: http://windowssecrets.com/forums/sho...Maths-Tutorial or: http://www.gmayor.com/downloads.htm#Third_party
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
One email with 2 photos attached won't load | dijear | Outlook | 0 | 03-08-2015 07:48 PM |
Please Help for VBA Code for Attached File.. | krishnaoptif | Word VBA | 3 | 07-17-2012 12:29 AM |
Removing Attached Mailboxes | Hack | Outlook | 0 | 10-14-2011 06:09 AM |
Open an attached email and sent does not work | M_O_C | Outlook | 0 | 07-27-2011 09:36 AM |
value attached to a name | grilem2 | Excel | 3 | 04-15-2011 06:46 PM |