A customer of ours is a teacher, and each semester we word-process the
report cards for her students. The main document gives general
information about the curriculum that has been covered in that semester,
and merge fields are used to insert each child's name and various
grades, and the teacher's comments about that child. This "comments"
field is a generally a paragraph long, ranging from a minimum of one to
as many as maybe ten sentences long. Generally, it is all in regular
text (in other words, no bold, no italics) and so that is the way the
formatting is set up in the main document.
However, sometimes, within that "comments" paragraph, there will be a
reference to the name of a book or story, which the teacher wants in
italics. However, even if we enter the name of the book in italics in
the data document, when we merge it, the resulting paragraph is all
non-italic.
What we've had to do is to merge to a new document, go "find" the book
title references in the merged document, italicize them, and then save
the merged document. The obvious disadvantage is that if she decides to
make extensive changes to the data, we have to re-merge, thereby losing
the italics all over again.
Any way around this?
If not, is there some way to "mark" those spots that should be italic so
that if we do need to re-italicize them, we can do it in some sort of
global search and replace operation rather than visually scanning for
each and every one?
Marlene
One way around this is to use a Wildcard Edit Replace on the datasource to
add a flag at the beginning and end of each italic formatted word. Then
when you execute the merge, each of those words in the merged result will be
identified with the flags and then you can use another Edit Replace to
reformat the words as italic.
On the Edit Replace for use on the datasource, click on the More button and
select the Wildcards box and click on the Format button, then Font, then
select Italic. In the Find what: box enter
([A-Za-z0-9]{1,})
and in ther Replace with box enter #\1#
When you execute the Find Replace, each italic word will have # inserted
before it and # inserted after it.
For the Edit Replace for use on the result of the mail merge, leave the
Wildcards box checked, and click on the Format button and then Font and then
select Normal. In the Find what: box enter
#([A-Za-z0-9]{1,})#
in the Replace with box, enter \1 and click on the Format button, then on
Font and then on Italic,
When you execute the Find Replace, the # flags will be deleted from each of
the words that they enclose and the words will be formatted as italic.
You can record each of these Edit Replace operations as a pair of macros so
that every time you get a new source document or execute a merge, you just
run the respective macro and it will take care of everything for you.
By way of explanation, the ([A-Za-z0-9]{1,}) that you use in the Find what
box tells Word to find any word that contains 1 {1,} or more of the
characters A-Z, a-z or 0-9 and the parentheses around this construction
define it as a group. The \1 in the replace with box tells Word to replace
it with the first (in this case the only group) found.
Hope this helps,
Doug Robbins - Word MVP
Please post any follow-up to the Newsgroups so that others may benefit
therefrom or contribute thereto.
Marlene McCall <cos-...@pacbell.net> wrote in message
news:38BDF260...@pacbell.net...
e.g. if the column in your table is called comments, you can use {ref
comments} instead of {mergefield comments}
You may be able to use just {comments} but it may clash with a built-in Word
field.
Peter Jamieson