Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / April 2006

Tip: Looking for answers? Try searching our database.

Insert certain paragraphs based on fields in Excel database

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MarvInBoise - 18 Apr 2006 21:00 GMT
Need to choose certain paragraphs to be inserted in Word document with mail
merge to an Excel file; the Excel file "letter" field can contain a character
defining the paragraph to be inserted, e.g., L=Liability pagragraph; the
"letter field can contain LCWG; each letter designates a different paragraph
be inserted.
Signature

Marv Lusk
Boise Corporation

Peter Jamieson - 18 Apr 2006 22:16 GMT
If your paragraphs are quite simple you should be able to use IF fields,
e.g.

{ IF "{ MERGEFIELD letter }" = "L" "put the text of your liability paragraph
here" ""
}{ IF "{ MERGEFIELD letter }" = "C" "put the text of your C type paragraph
here" ""
}

etc.

Use ctrl-F9 to insert each pair of {}, and type everything else in the usual
way.

Peter Jamieson

> Need to choose certain paragraphs to be inserted in Word document with
> mail
[quoted text clipped - 4 lines]
> paragraph
> be inserted.
MarvInBoise - 19 Apr 2006 14:38 GMT
Thank you, I played around with it and I think I can get it to work; however,
it only appears to work if I have one code in the "letter" field.  If I have
LWC in the field, meaning it gets 3 paragraphs, it doesn't seem to work; if I
only have L or W or C individually, then it works.  ??
Signature

Marv Lusk
Boise Corporation

> If your paragraphs are quite simple you should be able to use IF fields,
> e.g.
[quoted text clipped - 20 lines]
> > paragraph
> > be inserted.
Peter Jamieson - 19 Apr 2006 15:58 GMT
Ah, I see. That's more difficult, because it's hard to look at parts of a
string using Word fields. The /simplest/ thing to do in this case is to
separate the codes in Excel (e.g. have four columns and "L" or blank etc.)

In theory you could also have one IF field for every possible combination,
but that's quite a lot of IF fields, e.g.

{ SET L "N" }{ SET C "N" }{ SET W "N" }{ SET G "N" }
{ IF "{ MERGEFIELD letter }" = "L" "{ SET L "Y" }" ""
}{ IF "{ MERGEFIELD letter }" = "LC" "{ SET L "Y" }{ SET C "Y" }" ""
}

etc.

then { IF { L } = "Y" "put your L text here" "" }

and so on.

And that will only work if the sequence of the letters is irrelevant, i.e.
if LCW means use paras L, C, W in that order and LWC means use LWC in that
order, you would have to modifythat.

As long as you know that there can only be four letters and the sequence is
iirelevant you can cut the number of IF fields down by using wild cards,
e.g.

{ IF "{ MERGEFIELD letter }" = "L*" "{ SET L "Y" }" ""
}{ IF "{ MERGEFIELD letter }" = "*L" "{ SET L "Y" }" ""
}{ IF "{ MERGEFIELD letter }" = "?L*" "{ SET L "Y" }" ""
} IF "{ MERGEFIELD letter }" = "??L*" "{ SET L "Y" }" ""
}{ IF "{ MERGEFIELD letter }" = "C*" "{ SET C "Y" }" ""
}

and so on.

if you know that the sequence is always LCWG, i.e. you can have L, LC, CW,
LWG etc. but not CL, you can simplify that a bit:

{ IF "{ MERGEFIELD letter }" = "L*" "{ SET L "Y" }" ""
}{ IF "{ MERGEFIELD letter }" = "C*" "{ SET C "Y" }" ""
}{ IF "{ MERGEFIELD letter }" = "?C*" "{ SET C "Y" }" ""
}{ IF "{ MERGEFIELD letter }" = "W*" "{ SET W "Y" }" ""
}{ IF "{ MERGEFIELD letter }" = "?W*" "{ SET C "Y" }" ""
}

Alternatively, you can create a separate Word document - let's call it
c:\mydocs\paras.doc - containing the three paragraphs and create bookmarks
corresponding to each possible combination of letters. I would use bookmark
names "A", "AL", "AC" etc. where "A" means "none of the letters" because
then you can use

{ INCLUDETEXT "c:\\mydocs\\paras.doc" "A{ MERGEFIELD letter }" }

to include the correct text. If the paragraphs can be in different
seqeunces, you will need to create each sequence of paras. in paras.doc and
assign the appropriate bookmarks to each sequence.

It may be possible to do this a simpler way but my brain's not firing on all
cylinders at the moment...

Peter Jamieson
{ IF "{ MERGEFIELD letter }"
> Thank you, I played around with it and I think I can get it to work;
> however,
[quoted text clipped - 32 lines]
>> > paragraph
>> > be inserted.
MarvInBoise - 19 Apr 2006 16:31 GMT
WOW, thanks Peter!  You have given me many paths to pursue; I appreciate it!
Signature

Marv Lusk
Boise Corporation

> Ah, I see. That's more difficult, because it's hard to look at parts of a
> string using Word fields. The /simplest/ thing to do in this case is to
[quoted text clipped - 94 lines]
> >> > paragraph
> >> > be inserted.
MarvInBoise - 20 Apr 2006 18:12 GMT
Thanks Peter; I had to diddle around a bit more with the paragraph returns,
but I think I've got it.  Thanks again!
Signature

Marv Lusk
Boise Corporation

> WOW, thanks Peter!  You have given me many paths to pursue; I appreciate it!
>
[quoted text clipped - 96 lines]
> > >> > paragraph
> > >> > be inserted.
MarvInBoise - 20 Apr 2006 16:01 GMT
Sorry Peter, but here I am again!  I have the merge working based on letter
type (I did have to split it out into separate columns). Now my challenge
appears to be spacing and line returns based on whether paragraphs are merged
or not. Here is my code:

To continue to be an Approved Carrier for....:
{IF{MERGEFIELD "LetterG"} = "G"
"Certificate of General Liability...
   rest of paragraph"}
{IF{MERGEFIELD "LetterL"} = "L"
"Certificate of General Liability...
   rest of paragraph"}
{IF{MERGEFIELD "LetterC"} = "C"
"Certificate of General Liability...
   rest of paragraph"}
{IF{MERGEFIELD "LetterW"} = "W"
"Certificate of General Liability...
   rest of paragraph"}
All insurance.....
Signature

Marv Lusk
Boise Corporation

> Need to choose certain paragraphs to be inserted in Word document with mail
> merge to an Excel file; the Excel file "letter" field can contain a character
> defining the paragraph to be inserted, e.g., L=Liability pagragraph; the
> "letter field can contain LCWG; each letter designates a different paragraph
> be inserted.
Peter Jamieson - 20 Apr 2006 16:24 GMT
If you always need a blank line (blank para.) at the bginning of each of
your text paragraphs, you can put a new para immediately after the ", e.g.

instead of

{ IF{ MERGEFIELD "LetterG" } = "G"
"Certificate of General Liability...
rest of paragraph" "" }

try

{ IF{ MERGEFIELD "LetterG" } = "G"
"
Certificate of General Liability...
rest of paragraph" "" }

etc.

Peter Jamieson

> Sorry Peter, but here I am again!  I have the merge working based on
> letter
[quoted text clipped - 26 lines]
>> paragraph
>> be inserted.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.