Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Ron40 Ron40 is offline
external usenet poster
 
Posts: 1
Default If statement to insert word file

I am using mail merge to extract fields from an excel file. What I would like
to do is if one of the fields meets a certain condition I would like to
insert another word file into the document. How would I write that if
statement?
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default If statement to insert word file

You can try

Suppose your test field is called myfield and you want to compare it with
"abc", and include the document "c:\myfolder\mydoc.doc" if it matches. Then
try

{ IF "{ MERGEFIELD myfield }" = "abc" "{ INCLUDETEXT
"c:\\myfolder\\mydoc.doc" }" "" }

All the {} need to be the special field code braces that you can insert
using ctrl-F9. Everything else is plain text. Not the doubled-up backslashes
(although you can probably use single forward slashes instead).

However, you may find that your included file does not actually update
correctly if you do that, and in many situations it's better if you can
"invert" the nesting so you have something more like

{ INCLUDETEXT "c:\\myfolder\\{ IF "{ MERGEFIELD myfield }" = "abc"
"mydoc.doc" "empty.doc" }" }

where empty.doc is an empty Word doc. However, the problem with /that/ is
that will get an extra paragraph mark - if you don't want it, what you can
do instead is
a. select the complete text of mydoc.doc and use insert|bookmark to insert
a bookmark called "all" (say)
b. select a single point in mydoc.doc and insert a bookmark called "none"
c. use

{ INCLUDETEXT "c:\\myfolder\\mydoc.doc" { IF "{ MERGEFIELD myfield }" =
"abc" "all" "none" } }

--
Peter Jamieson
http://tips.pjmsn.me.uk

"Ron40" wrote in message
...
I am using mail merge to extract fields from an excel file. What I would
like
to do is if one of the fields meets a certain condition I would like to
insert another word file into the document. How would I write that if
statement?


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
which statement right , question is Choose the correct statement? how many template?when we click new doc Microsoft Word Help 1 October 16th 06 11:15 AM
which statement right , question isChoose the correct statement? how many template?when we click new doc Microsoft Word Help 1 October 15th 06 11:20 PM
why can't i create a pdf file from word to a statement size suzyq Microsoft Word Help 1 February 6th 06 03:38 PM
How do I insert different pictures using and If statement in Word. Rob69 Mailmerge 2 April 20th 05 10:42 PM
Insert carriage return in mergefield statement dixie Mailmerge 2 December 22nd 04 03:42 AM


All times are GMT +1. The time now is 03:16 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"