Hi,
In the IF statement you must enclose each result in quotation marks, and if
you want the result to be text from another document, rather than the whole
document, you should specify a bookmark from the other document, for example,
a bookmark named TextA. The following modified version of your IF field
should work.
{IF {BM2}="CV*" "{INCLUDETEXT "C:\\documents\\textA.doc" TextA}" "Error"}
Be sure to create all the pairs of curly brackets by selecting and pressing
Ctrl+F9.
FWIW there is slightly more to it than this, e.g.
a. One-off inclusions (e.g. where you execute the { IF } field
manually) should work. But in a mailmerge, the IF field may only be
evaluated once in an output document (i.e. you may have to select the
output document and re-execute the fields). Inverting the nesting so
that you have an IF inside of an INCLUDETEXT, as Graham has suggested,
is sometimes a solution for this problem
b. In the general case it's advisable to surround REF fields by
quotes, e.g.
With
{IF {BM2}="CV*" "{INCLUDETEXT "C:\\documents\\textA.doc" TextA}" "Error"}
If the value of the bookmark BM2 is "mybm" and there happens to be a
bookmark in the document called mybm, instead of comparing
the value of bookmark BM2 with "CV*"
Word will compare
the value of bookmark mybm with "CV*"
If you use
{IF "{BM2}"="CV*" "{INCLUDETEXT "C:\\documents\\textA.doc" TextA}" "Error"}
that particular problem should be avoided.
c. Personally I prefer to surround the "true" and "false" results by
double quotes as you have suggested because
(1) it's a consistent approach that always seems to work and
(2) it's what Microsoft generally seems to have put in their
documentation, i.e. the nearest thing to a "documented syntax" that we have
but that said, it does not appear to be necessary in the cases where a
result consists of a single field, or a single text token.
Peter Jamieson
http://tips.pjmsn.me.uk