Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Inserting merge code into an If...Then statement
I'm using Word 2003 with an Excel spreadsheet as my data source to create a
merge in a lengthy document. I need an If...Then-type field that will allow me to have another field code in the Insert This Text area. Example: If: "Spouse_Y_N" Is Equal to: "Yes", then insert: [Spouse Name]. Where Spouse Name is also a field pulling from the same Excel spreadsheet. Any ideas on how I can achieve this? Thanks in advance. |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Inserting merge code into an If...Then statement
Hi,
In Word: .. Insert a «Spouse_Y_N» mergefield followed by a «Spouse_Name» mergefield ; .. select both mergefields and press Ctrl-F9 to enclose them in a new field, thus {«Spouse_Y_N»«Spouse_Name»}; .. fill in around the new field braces thus, paying careful attention to the spacing {IF{«Spouse_Y_N»= "Yes" «Spouse_Name»}; .. position the cursor anywhere in this field and press F9 to update it; .. run your mailmerge. If your «Spouse_Y_N» mergefield can contain 'Yes', 'yes', 'Y' or 'y' for a 'Yes response, you'll need to do a bit more work. In this case, when you forst insert the «Spouse_Y_N» mergefield: .. select it and press Shift-F9. You should see {MERGEFIELD Spouse_Y_N} .. add an uppercase switch to it, thus: {MERGEFIELD Spouse_Y_N \* Upper} .. press F9 to update the field .. continue as before, except that you code the overall field as {IF{«Spouse_Y_N»= "Y*" «Spouse_Name»} -- Cheers macropod [MVP - Microsoft Word] "Veteran of the software cycles" . com wrote in message ... I'm using Word 2003 with an Excel spreadsheet as my data source to create a merge in a lengthy document. I need an If...Then-type field that will allow me to have another field code in the Insert This Text area. Example: If: "Spouse_Y_N" Is Equal to: "Yes", then insert: [Spouse Name]. Where Spouse Name is also a field pulling from the same Excel spreadsheet. Any ideas on how I can achieve this? Thanks in advance. |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Inserting merge code into an If...Then statement
macropod,
Here's what I did: inserted two merge fields, selected them, pressed Ctrl-F9, typed "IF{" INSIDE the first bracket, typed ="Yes" between 2 merge fields. When I press F9 to update the coding, it immediately runs that sequence, inserting spouse's name ("Anna Bannana"), rather than leaving the coding. In my dropdown Insert Word Field list, I don't have an "{IF" code. When I typed "{IF" outside the first brace, it does not become part of the totalcode when I press F9, which is why I typed "IF{ inside the first brace. Many thanks for your help so far. "macropod" wrote: Hi, In Word: .. Insert a «Spouse_Y_N» mergefield followed by a «Spouse_Name» mergefield ; .. select both mergefields and press Ctrl-F9 to enclose them in a new field, thus {«Spouse_Y_N»«Spouse_Name»}; .. fill in around the new field braces thus, paying careful attention to the spacing {IF{«Spouse_Y_N»= "Yes" «Spouse_Name»}; .. position the cursor anywhere in this field and press F9 to update it; .. run your mailmerge. If your «Spouse_Y_N» mergefield can contain 'Yes', 'yes', 'Y' or 'y' for a 'Yes response, you'll need to do a bit more work. In this case, when you forst insert the «Spouse_Y_N» mergefield: .. select it and press Shift-F9. You should see {MERGEFIELD Spouse_Y_N} .. add an uppercase switch to it, thus: {MERGEFIELD Spouse_Y_N \* Upper} .. press F9 to update the field .. continue as before, except that you code the overall field as {IF{«Spouse_Y_N»= "Y*" «Spouse_Name»} -- Cheers macropod [MVP - Microsoft Word] "Veteran of the software cycles" . com wrote in message ... I'm using Word 2003 with an Excel spreadsheet as my data source to create a merge in a lengthy document. I need an If...Then-type field that will allow me to have another field code in the Insert This Text area. Example: If: "Spouse_Y_N" Is Equal to: "Yes", then insert: [Spouse Name]. Where Spouse Name is also a field pulling from the same Excel spreadsheet. Any ideas on how I can achieve this? Thanks in advance. |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Inserting merge code into an If...Then statement
If you use Alt+F9 to toggle on the display of the field codes, the field
construction should look like { IF { MERGEFIELD Spouse_Y_N } = "Yes" { MERGEFIELD "Spouse Name" } } where each pair of field delimiters { } was either converted from the mergefieldname or by using Ctrl+F9 Use Alt+F9 to toggle off the display of the field codes. Pressing F9 to update the field, may cause it to display the result for the current record in the data source. If you execute the merge however, you should get the appropriate result for each record. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Veteran of the software cycles" . com wrote in message ... macropod, Here's what I did: inserted two merge fields, selected them, pressed Ctrl-F9, typed "IF{" INSIDE the first bracket, typed ="Yes" between 2 merge fields. When I press F9 to update the coding, it immediately runs that sequence, inserting spouse's name ("Anna Bannana"), rather than leaving the coding. In my dropdown Insert Word Field list, I don't have an "{IF" code. When I typed "{IF" outside the first brace, it does not become part of the totalcode when I press F9, which is why I typed "IF{ inside the first brace. Many thanks for your help so far. "macropod" wrote: Hi, In Word: .. Insert a «Spouse_Y_N» mergefield followed by a «Spouse_Name» mergefield ; .. select both mergefields and press Ctrl-F9 to enclose them in a new field, thus {«Spouse_Y_N»«Spouse_Name»}; .. fill in around the new field braces thus, paying careful attention to the spacing {IF{«Spouse_Y_N»= "Yes" «Spouse_Name»}; .. position the cursor anywhere in this field and press F9 to update it; .. run your mailmerge. If your «Spouse_Y_N» mergefield can contain 'Yes', 'yes', 'Y' or 'y' for a 'Yes response, you'll need to do a bit more work. In this case, when you forst insert the «Spouse_Y_N» mergefield: .. select it and press Shift-F9. You should see {MERGEFIELD Spouse_Y_N} .. add an uppercase switch to it, thus: {MERGEFIELD Spouse_Y_N \* Upper} .. press F9 to update the field .. continue as before, except that you code the overall field as {IF{«Spouse_Y_N»= "Y*" «Spouse_Name»} -- Cheers macropod [MVP - Microsoft Word] "Veteran of the software cycles" . com wrote in message ... I'm using Word 2003 with an Excel spreadsheet as my data source to create a merge in a lengthy document. I need an If...Then-type field that will allow me to have another field code in the Insert This Text area. Example: If: "Spouse_Y_N" Is Equal to: "Yes", then insert: [Spouse Name]. Where Spouse Name is also a field pulling from the same Excel spreadsheet. Any ideas on how I can achieve this? Thanks in advance. |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Inserting merge code into an If...Then statement
Hi, guys, I got it to work. Many thanks.
"Doug Robbins - Word MVP on news.microsof" wrote: If you use Alt+F9 to toggle on the display of the field codes, the field construction should look like { IF { MERGEFIELD Spouse_Y_N } = "Yes" { MERGEFIELD "Spouse Name" } } where each pair of field delimiters { } was either converted from the mergefieldname or by using Ctrl+F9 Use Alt+F9 to toggle off the display of the field codes. Pressing F9 to update the field, may cause it to display the result for the current record in the data source. If you execute the merge however, you should get the appropriate result for each record. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Veteran of the software cycles" . com wrote in message ... macropod, Here's what I did: inserted two merge fields, selected them, pressed Ctrl-F9, typed "IF{" INSIDE the first bracket, typed ="Yes" between 2 merge fields. When I press F9 to update the coding, it immediately runs that sequence, inserting spouse's name ("Anna Bannana"), rather than leaving the coding. In my dropdown Insert Word Field list, I don't have an "{IF" code. When I typed "{IF" outside the first brace, it does not become part of the totalcode when I press F9, which is why I typed "IF{ inside the first brace. Many thanks for your help so far. "macropod" wrote: Hi, In Word: .. Insert a «Spouse_Y_N» mergefield followed by a «Spouse_Name» mergefield ; .. select both mergefields and press Ctrl-F9 to enclose them in a new field, thus {«Spouse_Y_N»«Spouse_Name»}; .. fill in around the new field braces thus, paying careful attention to the spacing {IF{«Spouse_Y_N»= "Yes" «Spouse_Name»}; .. position the cursor anywhere in this field and press F9 to update it; .. run your mailmerge. If your «Spouse_Y_N» mergefield can contain 'Yes', 'yes', 'Y' or 'y' for a 'Yes response, you'll need to do a bit more work. In this case, when you forst insert the «Spouse_Y_N» mergefield: .. select it and press Shift-F9. You should see {MERGEFIELD Spouse_Y_N} .. add an uppercase switch to it, thus: {MERGEFIELD Spouse_Y_N \* Upper} .. press F9 to update the field .. continue as before, except that you code the overall field as {IF{«Spouse_Y_N»= "Y*" «Spouse_Name»} -- Cheers macropod [MVP - Microsoft Word] "Veteran of the software cycles" . com wrote in message ... I'm using Word 2003 with an Excel spreadsheet as my data source to create a merge in a lengthy document. I need an If...Then-type field that will allow me to have another field code in the Insert This Text area. Example: If: "Spouse_Y_N" Is Equal to: "Yes", then insert: [Spouse Name]. Where Spouse Name is also a field pulling from the same Excel spreadsheet. Any ideas on how I can achieve this? Thanks in advance. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
MS Word 2003 Case statement code | Microsoft Word Help | |||
post code moves when inserting address into envelope or label | New Users | |||
why do I get embeded code on my document when inserting a chart | New Users | |||
Including a Merge Code Within an IF Statement | Mailmerge |