Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / October 2003

Tip: Looking for answers? Try searching our database.

running a macro during mail merge

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Imnotabum - 06 Oct 2003 23:40 GMT
Hello,

Would someone please tell me if it is possible to run a macro during a
mail merge? I would like the results of certan merge fields in the new
documents to be based on certain conditions in the datasource. e.g. If
the first record of the datasource has the value of one in the
Customer_Agmt field, then the first merged document should result in
"Customer Agreement" for that corresponding merge field; If there is a
1 in the Trading_Agmt field, then the result should be "Trading
Agreement". Conversely if there is a zero in either of those fields of
the datasource, then the merged document would not list anything. In
some instances, the there can be up to 9 possible entries for one
field. Any help will be appreciated.

I am using Office 2000.
Peter Jamieson - 07 Oct 2003 09:13 GMT
> I am using Office 2000.

You only get to run macros /during/ the merge in Word 2002, which uses
'mailmerge events' to let you do this.

So your options are:
a. use IF fields to substitute pieces of text for the values in your data
source
b. control the merge from a macro, output to a document, and postprocess
the results
c. control the merge from a macro, doing one merge per record in the data
source, and stuff in whatever you want based on the values of the fields in
the mailmerge.datasource.datafields collection.

From what you say, it sounds as if (a) would be enough, e.g.

{ IF { MERGEFIELD Customer_Agmt } = 1 "Customer Agreement" "some other text
of fields or blank" }

etc. You can also nest IF fields (but there is a limit of around 20 to the
levels of nesting permitted).

Is that enough for your requirement?

--
Peter Jamieson
MS Word MVP

> Hello,
>
[quoted text clipped - 11 lines]
>
> I am using Office 2000.
Imnotabum - 08 Oct 2003 20:52 GMT
"Is that enough for your requirement?"

Yes, thank you for your kind response.

> > I am using Office 2000.
>
[quoted text clipped - 39 lines]
> >
> > I am using Office 2000.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.