Solved

Send a mailmerge email - code in vb to take info from a spreadsheet

Posted on 2011-09-27
1
269 Views
Last Modified: 2012-05-12
I have a data source file (excel) and a template. I tried to do a mailmerge, but my problem lies in the fact that I need to send multiple lines of data to the same agent. (when agent name is the same). Please see the two files attached and maybe you can give me some direction on how to do this.

so for example:
If agent name is Amy X
Display all lines in the mailmerge where agent name is Amy X. This may be 1 line or 10 lines

thanks in advance Email.docx
List.xlsx
0
Comment
Question by:damixa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 36713291
This is a one-to-many situation.

Mail merge is not designed to do that, but there are several workaround methods. Which is best depends on the details of the data and your skill level. If you need further help with any of the methods, let us know.

There are a couple of techniques that do not use VBA.

If you have a limited number of subsidiary items, you can arrange your datasource so that each item has its own field.
e.g.

Forename, Surname, address1, address2, postcode, item1, item2, item3, item4,... itemN.

Another is to use Word Fields IF and MERGESEQ
http://support.microsoft.com/kb/294686/

Here are four approaches that use VBA.

This one uses VBA (in Access, but it could be in Word)  to create an individual document per customer.
http://www.experts-exchange.com/Applications/MS_Office/Word/Q_21090605.html

This talks about hooking into the  MailMergeAfterRecordMerge event to create a recordset for each customer's orders.
http://www.experts-exchange.com/Applications/MS_Office/Word/Q_21478463.html

Here VBA is used to split a single-table merge output into individual tables.
http://www.experts-exchange.com/Applications/MS_Office/Word/Q_21633674.html

This one is a Directory type merge to a Word table. The datasource is a flat file or the result of a one-to-many query. The merge fields are set up in the Word table to receive the 'many' data.

The MailMergeBeforeRecordMerge event is used to look for a change of data in the One table. It then starts a new document Section, saves the data from the one side fields using Word VBA techniques, and carries on until the next change.
http://www.experts-exchange.com/Applications/MS_Office/Word/Q_21669663.html
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question