View Single Post
  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Insert file based on contents of merge field

If this is exactly what you typed:

{QUOTE {INCLUDETEXT "C:\\Users\John\Desktop\\{ MERGEFIELD artnr }.docx"}}

then you need another backslash after "Users" and after "John", i.e.

{QUOTE {INCLUDETEXT "C:\\Users\\John\\Desktop\\{ MERGEFIELD artnr
}.docx"}}

Also be very careful to ensure that there are no spaces that should not
be there (it's very easy to insert them by accident, especially when
using copy/paste).

Peter Jamieson

http://tips.pjmsn.me.uk

On 08/01/2010 11:51, lion wrote:
Hello Doug,

There is still an error in the code.
For test purposes I have a small text file with the name of x1.docx
The contents of the field "artnr" is: "x1"
In the main document I typed the code:
{QUOTE {INCLUDETEXT "C:\\Users\John\Desktop\\{ MERGEFIELD artnr }.docx"}}
(field delimiters inserted with CTRL+F9)
The document to be inserted is on the desktop of user John and is called:
x1.docx

When I run the mail merge, I get the following error:

"A field calculation error occurred in record 1"

The contents of document x1.docx is not inserted in the main document and
the field is changed to:
{QUOTEError! Not a valid filename.}

Is there something I didn't see?

Thanks for your help!

"Doug Robbins - Word MVP" wrote:

Use the following field construction in your mail merge main document

{QUOTE {INCLUDETEXT "C:\\Document Path\\{ MERGEFIELD Article }.docx"}}

replacing the Article with the name of the merge field that contains the
number such as 123.

Note that you must use Ctrl+F9 to insert each pair of field delimiters { }
--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

wrote in message
...
Hello,
Does somebody know if (and how) it is possible to insert a file in a Word
2007 document, based on the contents of a merge field?
The merge field contains a number. If the numer is 123, the file 123.docx
should be inserted. This file contains the (long) description of article
123.
It is very important that the text keeps its formatting. That's why the
long
description cannot be entered in the database.
All help appreciated!


.