Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mail-merging with Word, MySQL... and Perl?
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! |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mail-merging with Word, MySQL... and Perl?
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. -- 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 "George Adams" wrote in message ... 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! |
Reply |
Thread Tools | |
Display Modes | |
|
|