View Single Post
  #5   Report Post  
Posted to microsoft.public.word.newusers,microsoft.public.word.vba.general
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default VBA code to execute for a subsequent mail merge

Other than Doug's suggestion, there are three or four ways you could do
this:
a. There are macros for exporting data from Outlook on www.slipstick.com -
you might need to adapt them
b. Ideally, you would be able to issue an OpenDataSource command from Word
to connect to the Outlook data source and issue SQL to construct the fields
you need. Unfortunately, there does not appear to be a simple way to do that
without being prompted for the Outlook contacts folder name. However, if you
have Access, I think you will be able to
- set up a linked table to your contacts folder
- set up a query that returns the fields you need
- use that as the data source
The trouble is that this method does not return as many of the fields in the
contacts folder as the "starting from Outlook" approach does. So even if the
basic idea works, you may not be abble to get the data you need. And it is
ludicrously complicated.
c. use Word Mail Merge Events to manipulate the data and stuff it into the
correct places in your document
d. consider "rolling your own" merge by automating from Outlook and
stuffing the values in each contact into Word Document Properties or
Document Variables, inserting them into your document using DOCPROPERTY or
DOCVARIABLE fields.

Peter Jamieson

"Colonel Blip" wrote in message
...
Hello, All!

My outlook 2k3 contact form is the default. The contact names take the
form
of Full Name made up of First Name and Last name. First name for a husband
and wife is of the form "Jack & Jill". I need, in a mail merge to be able
to
separate this field into two fields if the & exists in the First_Name
field.
I was hoping I could do in using Word's IF...Then... Else but I can't.

While I normally create my mailmerge using the OL Tool|Mail Merge wizard,
that is not necessary since I have my document designed and simply need
the
data exported. Is there a way with a macro in OL to export Contacts in a
form that would be usable by Word's mailmerge, but as it does so to do the
following:

1. Check the OL First_Name field.
2. If there is a "&" in the field place the second name in the Spouse
field
and drop the "&" and following and put the remaining name in the
First_Name
field of the merge data file.
3. If there is not a "&" in the First_Name field then do not modify the
field.

I could then reconstruct the couples with the IF statement in Word, but I
would have the couples names in separate fields to be able to use them in
other conditional command I want to use.

Thanks,
Colonel Blip.
E-mail: