?
Solved

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

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

770 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