Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
lion lion is offline
external usenet poster
 
Posts: 5
Default Insert file based on contents of merge field

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!
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Insert file based on contents of merge field

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.

"lion" 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!


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
lion lion is offline
external usenet poster
 
Posts: 5
Default Insert file based on contents of merge field


Thanks Doug,
I'll try it today!



"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.

"lion" 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!


.

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

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.

"lion" 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!


.

  #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!


.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge - insert different phrase based on date value? Martha Mailmerge 1 August 27th 09 05:31 AM
Page Break based on merge field Mark B Mailmerge 1 February 11th 07 04:41 AM
Using a macro to insert a web-based file Justible Microsoft Word Help 3 August 17th 06 11:39 PM
Possible to insert a file into Word based on a mail merge field? Mark Mailmerge 1 January 13th 06 03:50 PM
Insert a file into a merge field kim Mailmerge 1 July 18th 05 05:13 PM


All times are GMT +1. The time now is 04:44 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"