View Single Post
  #9   Report Post  
Peter Jamieson
 
Posts: n/a
Default

I am using 2003, so I assume this is how the first sentence should read.
Is
there some documentation as to what a Directory-type mail merge main
document
actually is?


If you look at Word Help, Table of Contents, Mass Mailings, you may find an
item titled "Word mail merge: A walk through the process" which is a link to
a page somewhere on the Office web site.

I say "you may find" only because these days the contents of Word Help are
updated dynamically from the web so I can't be sure this particular link
will show up on your system.

There are several types of Mail Merge Main Document, e.g. Labels, Letter,
Directory and a few others. The essential differences between a Letter merge
and a Directory merge are as follows:

In a typical Letter merge, Word takes each record in the data source and
generates a outputs one letter for each record in the data source, i.e. if
the "destination" of the merge is a printer, Word starts each new letter at
the top of a new sheet of paper. The destination of a Letter merge can be a
printer, e-mail (and, in theory, fax), or a new document. If the destination
is e-mail or fax, each letter is sent to a single recipient. If the
destination is a new document, Word generates a single document with one
Word Section for each record in the data source.

In a Directory merge, Word does not start on a new page/section for each
record in the data source. If, for example, the mail merge main document has
five lines of text and fields, Word will output 5 lines for record 1 in the
data source, followed immediately by five lines for record 2, etc. If the
mail merge main document contains a single table row, Word will output a
table containing one row for each record in the data source. The only
destination you can successfully specify for a directory merge is a new
document.

If I am understanding this correctly, even though doug says he can't
explain
thsi any better, the directory-type thing above creates a table with the
email address and the specific attachment. If so, my question is, can't I
just have this ready to go in excel?


Well, you could have it in Excel, but then the macro code in the referenced
article would have to be different because currently it relies on the list
of attachments being in a Word table. If the list were in an Excel document,
the code would need to be substantially different.

Or am I totally confused...


Maybe :-) The trouble is that anything I say is quite likely to compound
your confusion as it is difficult to explain some of this stuff without
lapsing into technical jargon Also, I didn't write the article, so cannot be
sure I have understood the authors' reasons for their approach. But here
goes...

1. The objective is to be able to send personalised e-mails with attachments
to a number of recipients. This is not possible "out of the box" using Word
so the authors of the article have tried to work out a simple way to do it
using a combination of merges and macros.

2. The essence of the process is as follows
a. you have a Letter type mail merge main document (see above) used to
generate the personalised main body for each e-mail. This needs to be
attached to a mail merge data source with one record for each e-mail
recipient. Let's call this data source "LetterData". LetterData needs to
contain all the data used in the personalised body of the e-mail. Logically
speaking, it does not need to contain the names of the attachments for each
recipient, or even the recipient's e-mail address (although I suspect it
would at least contain the address wherever the data came from) . But let's
assume that LetterData does contain both of those things.
b. you open your mail merge main document and perform the merge, setting
the destination to be a new document. Let's call this document "Letters".
"Letters" will be a single new document containing one Word section for each
recipient.
c. At this point you use the macro provided in the article. In effect, this
takes the first section of "Letters" and copies it to the body of a new
e-mail message, addressed to the first recipient in the data source. It
determines which files should be sent to this recipient and attaches them,
then sends the message. This process is repeated for each section in
"Letters", i.e. for each recipient.

3. In order to do this, the macro could get all the necessary data from
LetterData. But how does it do that? The trouble is that the code needed
depends on the type of data source. So for example, if LetterData is a Word
document, the obvious method is to use Word Automation. If LetterData is an
Excel workbook, Word Automation is no good - you could try Excel Automation.
If LetterData is an Access table, you could use a number of methods,
including ADO, DAO etc. But they are all different. In fact the only /easy/
way to generalise this code would be to turn "Letters" into a Mail Merge
Main Document, attach LetterData to it as the data source, and use the
methods of the Mailmerge.DataSource object to iterate through the data
without actually performing a merge. Unfortunately, even that is harder than
it sounds because programmatically opening an arbitrary data source is a
non-trivial exercise. For some types of data source it's easy, but for
others it's quite difficult.

4. So what is the technical solution? The user could have their attachment
data in any format. By using a separate catalogue merge, the user can take
their attachment data and generate a file in a known format (a table within
a Word document). With any luck, it should be fairly easy for the user to
set this up manually in the usual way. The code in the article only has to
deal with that one format of data, and the process is also arguably simpler
because Word VBA knows all bout Word objects and no external objects or code
libraries are needed.


Peter Jamieson

"Mark B" wrote in message
...
In Word mailmerge, you can create a "Directory" as output. "Catalogue" is
the term used in older versions of Word for the same thing.


Thank you Peter! Maybe you can explain the rest of this to me...

"You will need to create a separate Directory-type mail merge main
document"

I am using 2003, so I assume this is how the first sentence should read.
Is
there some documentation as to what a Directory-type mail merge main
document
actually is?

"... which creates a word document containing a table in each row of which
would be data from the data source that contains the email address in the
first column and the Drive:\Path\Filename of each attachment in the second
and any subsequent columns, one attachment per cell."

If I am understanding this correctly, even though doug says he can't
explain
thsi any better, the directory-type thing above creates a table with the
email address and the specific attachment. If so, my question is, can't I
just have this ready to go in excel? Or am I totally confused...