1

I'm setting up a mail merge file that reads from a CSV file. In the CSV file, there are ~20 Boolean fields that produce the body of the Word mail merge file. The problem is that if the first 19 fields are all "N", then the Word mail merge file will have 19 blank spaces and then output the 20th field underneath all of them. Is there any way to suppress the output of these blank lines using the built-in mail merge rules?


Here's the header and a sample row of the CSV file:
"firstname","lastname","PRNT1040","LEGALGRD","ACADTRAN","STUD1040","VERWKSIN","VERWKSDP","UNEMPLOY","SSCARD","HSDPLOMA","DPBRTCFT","DEATHCRT","USCTZPRF","SLCTSERV","PROJINCM","YTDINCM","LAYOFFNT","MAJRCARS","W2FATHER","W2MOTHER","W2SPOUSE","W2STUDNT","2YRDEGRE","4YEARDEG","DPOVERRD"
"Joe","Smith","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","Y"

Here's a couple lines of the mail merge file that I'm trying (image linked because copying and pasting of mail merge does not show original document)

msword_mailmerge


Does anyone know how to get around this? I tried placing the SKIPIF in front of the conditionals, but that doesn't work either.
demongolem
  • 9,474
  • 36
  • 90
  • 105
CheeseConQueso
  • 5,831
  • 29
  • 93
  • 126

3 Answers3

1

The following conditional IF field will eliminate a blank space caused by an empty middle initial field:

{FNAME} {IF {MI} <> "" "{MI} "}{LNAME} 

The following conditional MERGEFIELD field will remove blank spaces in any field. For example, given the following fields,

{Prefix} {FirstName} {LastName} 

the following conditional statements will properly suppress the space normally included for any blank fields:

{IF {MERGEFIELD Prefix}<>"" "{MERGEFIELD Prefix} "}
{IF {MERGEFIELD FirstName}<>"" "{MERGEFIELD FirstName} "}
{IF {MERGEFIELD LastName}<>"" "{MERGEFIELD LastName}"} 

To enter the field characters ({}), choose Field from the Insert menu (or press CTRL+F9).

NOTE: Are you creating your csv by unloading the data from informix and replacing the pipe delimiter with commas?... maybe it would be better for you to create an ace report which can better manipulate strings to create the csv file! here's an example of an ace report I use to achieve a similar objective:

database pawnshop end

define
variable act integer
variable actven integer
variable ret integer
variable ven integer
variable cmp integer
variable plt integer
variable vta integer
variable tot integer
variable totprof integer
end


output
top margin 0
bottom margin 0
left margin 0
right margin 384 
report to "clientes.unl"
page length 200000
end


select
       pa_serial,
       pa_code,
       pa_store_id,
       pa_user_id,
       pa_cust_name,
       pa_id_type,
       pa_id_no,
       pa_dob,
       pa_address1,
       pa_city,
       pa_tel,
       pa_cmt,
       pa_entry_date,
       pa_last_date,
       pa_idioma,
       pa_apodo,
       pwd_id,
       pwd_trx_type,
       pwd_last_type,
       pwd_last_pymt,
       pwd_trx_date,
       pwd_pawn_amt,
       pwd_last_amt,
       pwd_cob1,
       pwd_cob2,
       pwd_cob3,
       pwd_cob4,
       pwd_update_flag,
       st_code,
       st_exp_days,
       st_com_exp,
       st_plat_exp 

  from CLIENTES, outer BOLETOS, storetab
 where pa_serial = pwd_id
   and pa_code = st_code
 order by pa_cust_name, pwd_last_pymt

end



format

on every row

if pwd_last_type = "E" then
begin
let act = act + 1
if today - pwd_last_pymt >= st_exp_days then
let actven = actven + 1
end


if pwd_last_type = "I" then
begin
let act = act + 1
if today - pwd_last_pymt >= st_exp_days then
let actven = actven + 1
end


if pwd_trx_type = "C" then
begin
let cmp = cmp + 1
if pwd_last_type = "C" and (today - pwd_last_pymt >= st_com_exp) then
let actven = actven + 1
end


if pwd_last_type = "R" then
begin
let ret = ret + 1
end


if pwd_trx_type = "P" and pwd_last_type = "P" then
begin
let plt = plt + 1
if today - pwd_last_pymt >= st_plat_exp then
let actven = actven + 1

end


if pwd_trx_type = "E" and pwd_last_type = "F" then
begin
let ven = ven + 1
end

if pwd_trx_type = "P" and pwd_last_type = "F" then
begin
let ven = ven + 1
end


if pwd_trx_type = "E" and pwd_last_type = "T" then
begin
let ven = ven + 1
end

if pwd_trx_type = "P" and pwd_last_type = "T" then
begin
let ven = ven + 1
end


before group of pa_cust_name
let totprof = 0
let tot = 0
let act = 0
let actven = 0
let ret = 0
let ven = 0
let cmp = 0
let plt = 0
let vta = 0


after group of pa_cust_name

print column 1, pa_serial using "<<<<<","|",
                pa_code clipped,"|",
                pa_store_id clipped,"|",
                pa_user_id clipped,"|",
                pa_cust_name clipped,"|",
                pa_id_type clipped,"|",
                pa_id_no clipped,"|",
                pa_dob using "mm-dd-yyyy","|",
                pa_address1 clipped,"|",
                pa_city clipped,"|",
                pa_tel clipped,"|",
                pa_cmt clipped,"|",
                pa_entry_date using "mm-dd-yyyy","|",
                pwd_last_pymt using "mm-dd-yyyy","|",
                act using "&&&","|",
                ret using "&&&","|",
                ven using "&&&","|",
                tot using "&&&","|",
                totprof using "-&&&&&","|",
                actven using "&&&","|",
                cmp using "&&&","|",
                pa_idioma,"|",
                pa_apodo,"|",
                plt using "&&&","|",
                vta using "&&&","|"
end
Joe R.
  • 2,032
  • 4
  • 36
  • 72
  • Thanks, I'll try this out today. ACE won't be able to fulfill the reqs here. it's a perl script that writes csv files, creates rollback files, logs user input & file paths, and emails the csv files to the executor so that he/she can push the data into a mail-merge file – CheeseConQueso Apr 27 '11 at 14:49
1

The simple thing would have been to skip the 'false' section in your IF condition.

Just write the true part

IF MERGEFIELD = "Y" "true section"

As you included false section, it will (i think) take into account

RichardTheKiwi
  • 105,798
  • 26
  • 196
  • 262
Vipin
  • 11
  • 1
0

We resolved the issue by changing the lines:

{ IF { MERGEFIELD PRNT1040} = "Y" "Write some text, then use a return line here " "" }

Then we put those rules back to back instead of putting the line breaks after each rule inside the dialogoe box - for some reason, Word parses out the line break after you finish going through the IF -> THEN -> ELSE rules included in word's mail-merge options.

CheeseConQueso
  • 5,831
  • 29
  • 93
  • 126