如何在 Microsoft Word 2007 邮件合并中抑制空行?

发布于 2024-11-03 07:27:20 字数 943 浏览 3 评论 0原文

我正在设置一个从 CSV 文件读取的邮件合并文件。在 CSV 文件中,有约 20 个布尔字段用于生成 Word 邮件合并文件的正文。问题是,如果前19个字段都是“N”,那么Word邮件合并文件将有19个空格,然后在所有空格下面输出第20个字段。有没有办法使用内置的邮件合并规则来抑制这些空行的输出?


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"

这是我正在尝试的邮件合并文件的几行(图像链接,因为复制和粘贴邮件合并不会显示原始文档)

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风和你 2024-11-10 07:27:20

以下条件 IF 字段将消除因中间首字母字段为空而导致的空格:

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

以下条件 MERGEFIELD 字段将删除任何字段中的空格。例如,给定以下字段,

{Prefix} {FirstName} {LastName} 

以下条件语句将正确抑制通常包含在任何空白字段中的空格:

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

要输入字段字符 ({}),请从“插入”菜单中选择“字段”(或按 CTRL+F9)。

注意:您是否通过从 informix 卸载数据并用逗号替换管道分隔符来创建 csv?...也许创建一个 ace 报告会更好,它可以更好地操作字符串来创建 csv 文件!这是我用来实现类似目标的 ace 报告的示例:

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

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
眼眸里的快感 2024-11-10 07:27:20

简单的事情就是跳过 IF 条件中的“false”部分。

只要写出真实的部分

IF MERGEFIELD = "Y" "true section"

当你包含虚假的部分时,它会(我认为)考虑到

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

醉酒的小男人 2024-11-10 07:27:20

我们通过更改以下行解决了该问题:

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

然后我们将这些规则背靠背放置,而不是在对话框内的每个规则后面放置换行符 - 出于某种原因,Word 在您完成 IF 后解析出换行符 -> THEN -> ELSE 规则包含在 Word 的邮件合并选项中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文