![]() |
|
![]() |
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
![]()
I have created a new merge document and merged in an Excel spreadsheet. The merge itself works perfectly--no problems, even after adding currency formatting to my fields. But when I try to adjust the display by adding IF statements, I don't get what I need--instead I just get the word "MERGEFIELD". There may be a better way to do this--if so, I'd appreciate help improving my methodology!
I am creating a series of receipts. Each receipt may have one or two line items (as specified in the flat Excel spreadsheet, nothing fancy here), and there may or may not be a discount applied. (I would have liked the Word file to do the math for me instead of importing all the amounts from Excel, but that's another issue entirely, I think!). The area where I am having a problem is that I only want text to be displayed in the discount field if there was, in fact, a discount. My pseudo code is this: If the merge field named "Item1_Discount" is not equal to zero, then display it, formatted as US currency with two decimal places. Else, display nothing. Before I started messing with the IF statement, my code was this, which worked perfectly, except that it displays $0.00 when the discount is zero (it says zero in the spreadsheet, rather than being blank), which is undesirable: Code:
{ MERGEFIELD "Item1_Discount" \# $0.00 } Code:
{ IF { MERGEFIELD Item1_Discount } <> "0" { MERGEFIELD Item1_Discount \# $0.00 } "" } So, thinking that my problem might have to do with the true value having a mergefield in it, I tried to simplify it: Code:
{ IF { MERGEFIELD Item1_Discount } <> "0" "yes" "no" } Even the simplified code produced the same results--the word "MERGEFIELD" instead of either nothing or the value saved in that field. I'm guessing that my problem is just a missing/extra space or bracket somewhere, but I can't, for the life of me, figure out what I've done wrong. I consulted with my non-Word-using husband, who can usually find my missing brackets and semi-colons in code in various languages, but he has no idea, either--though he was just going off the many tutorial pages available on the web, and not person experience with Word. I'm usually the person everyone I know comes to with their Word problems, but this has me completely stumped and feeling rather newbish and quite humbled, as I search in vain for a solution. So I'm hoping someone with far more Word experience than I possess might have a clue and be willing to share it. ![]() |
#2
|
||||
|
||||
![]()
Hi Eri,
You field syntax looks OK, so I suspect the issue may be related to the use of the field braces (ie '{}'). You cannot type these - for manual creation, they must be created in pairs via Ctrl-F9. In any event, you don't need an IF test - simply format the MERGEFIELD as: {MERGEFIELD "Item1_Discount" \# "$0.00;-$0.00;"} or: {MERGEFIELD "Item1_Discount" \# "$0.00;;"}
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to edit the "Format" and the "show level" of an EXISTING table of content? | Jamal NUMAN | Word | 2 | 08-14-2011 10:46 AM |
![]() |
lisa801 | Word | 3 | 07-08-2011 10:11 PM |
![]() |
Jamal NUMAN | Word | 4 | 07-08-2011 04:12 AM |
![]() |
Jamal NUMAN | Word | 2 | 07-03-2011 03:11 AM |
"Microsoft Excel Application" missing in the "Component Services" on win08 | sword.fish | Excel | 0 | 02-26-2010 02:09 PM |