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 / August 2007

Tip: Looking for answers? Try searching our database.

Mail-merging with Word, MySQL... and Perl?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
George Adams - 07 Aug 2007 22:05 GMT
I'm trying to do a mail-merge in Microsoft Word 2003 using an ODBC
connection to my MySQL database on my Linux box.  The finished product
will be a paper name/address/phone/etc. directory for our church.
Normally this would work fine, except I don't want to just simply grab
and merge the data from certain fields in the database.  I need to be
able to insert some programming logic.

For instance, I'll want to look at the age of the children listed in the
database, and if they're older than (say) 18, I won't display their
birthday.  Or if a couple has its anniversary listed, I'll want to
format that in BOLD and display it.  Or if the listed person is a
member, I'll want to format their name in a slightly different way.
etc. etc.  All of which is a little much for SQL to handle (or at least
for *me* to handle in SQL).

For a normal project, this would be a simple job for Perl.  What I can't
figure out is, is there anyway to insert Perl into this mail-merge
process?  Obviously MS-Word wants to query a database over ODBC, not a
Perl script.  Is there a way to change that so Word will get its data
from the  Perl script directly (which would be written to generate that
data in whatever format Word is looking for it?)

Thanks to anyone who can help!
Doug Robbins - Word MVP - 08 Aug 2007 00:33 GMT
You should be able to do what you want using If...then...Else fields in the
mail merge main document.

For example

{ IF { MERGEFIELD Age } < 18 "{ MERGEFIELD Birthdate }" "" }

{ IF { MERGEFIELD Anniversary } <> "" "{ MERGEFIELD Anniversary \*
Charformat }" "" }

To get the Anniversary displayed as Bold text, apply Bold formatting to the
M in "{ MERGEFIELD Anniversary \* Charformat }"

You must use Crtl+F9 to insert each pair of field delimiters { } and you use
Alt+F9 to toggle off their display.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> I'm trying to do a mail-merge in Microsoft Word 2003 using an ODBC
> connection to my MySQL database on my Linux box.  The finished product
[quoted text clipped - 19 lines]
>
> Thanks to anyone who can help!
 
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.