Trigger a find/replace on mail merge?

G

George Adams

I'm trying to make a directory, pulling in data from an ODBC database to
make a mail merge. For simplicity, let's just say the template looks
like this:

{ MERGEFIELD "lastname"}, { MERGEFIELD "firstname" }

All well and good. The only problem is that the database stores any
special characters as HTML entities (since the DB is primarily used for
displaying the directory on the web). Thus, the accent characters in
Jose Pinera (over the "e" in "Jose" and "n" in "Pinera") are stored in
the database as:

lastname: Piñera
firstname: José

Now, there are only a few of these, so a few search/replace commands
should be able to convert the HTML entities back into the actual
letters. I can't figure out how to incorporate this into the mail
merge, though. Is it possible to setup my document such that, with a
single push, the mail merge can run and a find/replace function can go
through "lastname" and "firstname", replacing all the HTML entities I
specify with their actual (ISO-8859-1) characters?

Thanks to anyone who can help!
 
P

Peter Jamieson

If you record a Word macro that merges to an output document, you can then
modify that macro so that it also does a number of find/replace operations
on the output document. All you really need to know is that when the merge
is complete, the output document is the ActiveDocument (if you need to do
things to the Mail Merge Main DOcument post-merge, make a reference to it
before you execute the merge).

You'll probably find plenty of samples of find/replace VBA code in the
word.vba newsgroups here, and probably at http://word.mvps.org as well.

Peter Jamieson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top