Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-09-27
1
Medium Priority
?
272 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 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes
Suggested Courses

610 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