Add Or Condition to Mail Merge

User avatar
Carol W.
3StarLounger
Posts: 390
Joined: 26 Jan 2010, 16:02
Location: Las Vegas, NV

Add Or Condition to Mail Merge

Post by Carol W. »

Please see attached zip file containing a Word 2010 mail merge template and xlsx file containing the source data.

I would like to add another condition for strLetterType = "Nevada's Big Give" and have the result be the same as that for strLetterType = "Philanthropic Programs". Once I get the logic properly placed, I will add a sentence or two to the body of the letter for Nevada's Big Give records.

Can I just add an or condition to strLetterType = "Philanthropic Programs"? If not, how would I do this?

Thanks in advance.
You do not have the required permissions to view the files attached to this post.
Carol W.

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Add Or Condition to Mail Merge

Post by HansV »

I can't find a condition for strLetterType = "Philanthropic Programs" in the merge document... :scratch:
Best wishes,
Hans

User avatar
Carol W.
3StarLounger
Posts: 390
Joined: 26 Jan 2010, 16:02
Location: Las Vegas, NV

Re: Add Or Condition to Mail Merge

Post by Carol W. »

I just double checked the file I sent. In the docx file, it's on page 8 of 9. See attached screenshot.

Did I mess up?
You do not have the required permissions to view the files attached to this post.
Carol W.

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Add Or Condition to Mail Merge

Post by HansV »

Sorry, I missed that one.

Macropod will probably come up with a clever field code, but I don't know of one. I'd simply add another If field with the desired condition, and duplicate the text for Philanthropic Programs.
Best wishes,
Hans

User avatar
Carol W.
3StarLounger
Posts: 390
Joined: 26 Jan 2010, 16:02
Location: Las Vegas, NV

Re: Add Or Condition to Mail Merge

Post by Carol W. »

I tried exactly what you suggest, namely adding another if field and changing the literal in the condition. However, I got tangled up in the brackets and the resulting merged document was blank. :hairout:

Thanks for trying.
Carol W.

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Add Or Condition to Mail Merge

Post by HansV »

Here is the merge document with the added letter for Nevada's Big Give.
Please note that the document is currently disconnected from its data source, you'll have to select the recipients again.
Mail Merge CS Document.docx
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
Carol W.
3StarLounger
Posts: 390
Joined: 26 Jan 2010, 16:02
Location: Las Vegas, NV

Re: Add Or Condition to Mail Merge

Post by Carol W. »

Thank you so much, Hans. As usual, you've come through! :thankyou:
Carol W.

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: Add Or Condition to Mail Merge

Post by macropod »

You might like to try the attached revision. Basically, I've transferred the bulk of the common content to a few SET fields at the start of the document (they almost fill the first page if you do Alt-F9), using REF fields to pull in the data, as appropriate to what remain as a series of independent (rather than nested) fields. That should make for easier maintenance and more consistent formatting.
You do not have the required permissions to view the files attached to this post.
Paul Edstein
[Fmr MS MVP - Word]

User avatar
Carol W.
3StarLounger
Posts: 390
Joined: 26 Jan 2010, 16:02
Location: Las Vegas, NV

Re: Add Or Condition to Mail Merge

Post by Carol W. »

Thanks, Paul. I probably should have done it this way in the first place.

I've implemented Hans' solution in production but I'm still trying to get your version of the template to work the way I want it to work. See attached screenshot for sample of letter (#1) that was generated.
Do I have to change the way I'm creating the Excel file to use your version? :scratch:
Macropod1.jpg
You do not have the required permissions to view the files attached to this post.
Carol W.

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: Add Or Condition to Mail Merge

Post by macropod »

Hi Carol,

That image suggests you haven't actually executed the merge yet or that its for an undefined letter type. And no, you shouldn't need to change anything in your Excel file. If you upload a sample data file, I can test & confirm that the field code work as I'd expect.
Paul Edstein
[Fmr MS MVP - Word]

User avatar
Carol W.
3StarLounger
Posts: 390
Joined: 26 Jan 2010, 16:02
Location: Las Vegas, NV

Re: Add Or Condition to Mail Merge

Post by Carol W. »

Paul,

I did execute the merge. I've attached a zip file containing an xlsx file containing four records, all for strLetterType = "Nevada's Big Give".

Thanks!
You do not have the required permissions to view the files attached to this post.
Carol W.

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: Add Or Condition to Mail Merge

Post by macropod »

See attached. Somehow I'd omitted "Nevada's Big Give" :scratch:
You do not have the required permissions to view the files attached to this post.
Paul Edstein
[Fmr MS MVP - Word]

User avatar
Carol W.
3StarLounger
Posts: 390
Joined: 26 Jan 2010, 16:02
Location: Las Vegas, NV

Re: Add Or Condition to Mail Merge

Post by Carol W. »

Thanks, Paul. Much better.
Carol W.