Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Includetext - field substitution 1

Status
Not open for further replies.

tonylilley

IS-IT--Management
Apr 12, 2006
2
GB
Using MS Word 97, I have a simple requirement, which is to insert text from a file name that is built from a mail merge field which is embedded in an INCLUDETEXT statement. Code for this is:

{INCLUDETEXT "C:\\customer\\contacts_pl_{ MERGEFIELD company}.doc" \* MERGEFORMAT}

All text is set to Arial 10 regular in the source and target files.

Because the field 'company' is not populated until the merge is performed the instruction generates the error 'Error! Cannot open file.' in arial bold.

When the merge takes place the text in the source file inserts ok, except that the first 4 words are bold and the following text is set to Times Roman. It looks like the first 4 words are adopting the style of the error message and then setting the remaining text to Times Roman.

Does anyone please have a suggestion / solution for this?
 
Hi Tony,

You can fix the output by changing the field code from:
{INCLUDETEXT "C:\\customer\\contacts_pl_{ MERGEFIELD company}.doc" \* MERGEFORMAT}
to:
{INCLUDETEXT "C:\\customer\\contacts_pl_{ MERGEFIELD company}.doc" \* CHARFORMAT}
and formatting the 'I' in 'INCLUDETEXT' to the required output font format (Arial 10 regular).

Additional coding could be used to suppress the error message in the main mailmerge document as follows, but it's only worth doing if you need to print it for others to review:
{IF{INCLUDETEXT "C:\\customer\\contacts_pl_{ MERGEFIELD company}.doc"}= "Error!*" "The merged company document appears here" {INCLUDETEXT "C:\\customer\\contacts_pl_{ MERGEFIELD company}.doc" \* MERGEFORMAT}}

Cheers
 

Thanks macropod - that seems to have worked fine.

Your help is much appreciated.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top