Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Thanks Ed that sounds quite a comprehensive reply to my query. I'll give it a
whorl tomorrow and let you know how I get on. My main problem was in how I actually got to insert the nested Ifs - using the insert word field didn't seem to do anything. The tip about Ctrl+F9 ans Alt+F9 is useful as I wasn't getting anything using Ctrl+F9. Will contact you tomorrow with my results. "Ed" wrote: Hi Pearl, Not sure how many levels of nesting you can have. An easy way to create many types of fields is just to type them into your document. Don't use the curly bracket keys on the keyboard to insert the field braces; instead use Ctrl+F9 to insert a pair of them. If you use Ctrl+F9 and don't see anything, press Alt+F9 to toggle field codes view on. If you're testing codes that are mutually exclusive you can often get away without having to nest the IF fields at all; just create them as un-nested and ensure that they are all on the same line. It's less elegant than nesting but should work (provided the codes cover all of the possibilities). The tricky part about nesting fields tends to be getting the structure right. Once you've nested to a few levels it can become hard to see the wood for the trees. However, if you are essentially nesting the same type of test over and over then one way to make it easy to get the structure right is to do the job in two stages. In stage one you create the nesting structure and in stage two you supply the values for the tests and results. If you want to replace codes with text (e.g. "IF code is "3" then insert "Text for 3" ELSE IF code is "4" THEN insert "Text for 4" etc.) you can do it as follows. First create the basic test. (Press Ctrl+F9 to get the field braces for the IF field, type IF followed by a space, press Ctrl+F9 again to get the field braces for the merge field and inside these braces type MERGEFIELD "code" (or whatever), then complete the IF field so that it looks something like the one below.) { IF { MERGEFIELD "code" } = "3" "Text for 3" "" } In this field, "Text for 3" is the TrueText (what you want displayed if the test evaluates to true) and "" is the FalseText (what you want displayed if the test evaluates to false). You can simulate an AND type of test by nesting into an IF field's TrueText and you can simulate an OR test by nesting into the FalseText. In this case, if I understand your requirement, I am going to repeatedly nest into the FalseText part of my fields (the final set of quotation marks) so I have left that part empty for now. To create the first level of nesting I copy the basic field (making sure I don't copy any trailing space or paragraph mark) and paste it into the relevant FalseText to get { IF { MERGEFIELD "code" } = "3" "Text for 3" "{ IF { MERGEFIELD "code" } = "3" "Text for 3" "" }" } I then paste it again into the (sole) set of empty quotation marks to produce the next level of nesting. I repeat the paste for as many levels of nesting as are required - each time just pasting into the empty quotation marks - no need to worry about the growing forest of quotation marks and curly brackets.. Once I've got all of the levels that I want I just go from the top and replace "3" with "4", "5" etc. as appropriate and amend each of the final TrueTexts to whatever it is I want to be displayed. Just having to paste the same thing into (in this case) the FalseText for as many levels of nesting as I want makes it very easy to get the nesting right. Once the nesting is right I can easily make the required substitutions. Depending on the circumstances I might also amend the final FalseText to be other than "". Hope this makes sense :-) Regards. Ed "Pearl" wrote: My data source contains codes e.g.3,4,5,14,16 that I want to change for text in my merged documents. First, how do I enter the multiple If statements? I think that I can write the nested If but don't know how to actually enter it in my document. I'm using Word 2000. Also how many nested Ifs will Word accept? |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
if statements with dates in mailmerge | Mailmerge | |||
How do I insert multiple hyperlinks in if, then, else statements? | Microsoft Word Help | |||
How do i use multiple IF statements in word 2000? | Mailmerge | |||
MERGE: Can I have multiple SET statements based on one IF | Mailmerge | |||
MERGE: Can I have multiple SET statements based on one IF | Mailmerge |