如何在 Microsoft Word 2007 邮件合并中抑制空行?
我正在设置一个从 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"
这是我正在尝试的邮件合并文件的几行(图像链接,因为复制和粘贴邮件合并不会显示原始文档)
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)
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下条件 IF 字段将消除因中间首字母字段为空而导致的空格:
以下条件 MERGEFIELD 字段将删除任何字段中的空格。例如,给定以下字段,
以下条件语句将正确抑制通常包含在任何空白字段中的空格:
要输入字段字符 ({}),请从“插入”菜单中选择“字段”(或按 CTRL+F9)。
注意:您是否通过从 informix 卸载数据并用逗号替换管道分隔符来创建 csv?...也许创建一个 ace 报告会更好,它可以更好地操作字符串来创建 csv 文件!这是我用来实现类似目标的 ace 报告的示例:
The following conditional IF field will eliminate a blank space caused by an empty middle initial field:
The following conditional MERGEFIELD field will remove blank spaces in any field. For example, given the following fields,
the following conditional statements will properly suppress the space normally included for any blank fields:
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:
简单的事情就是跳过 IF 条件中的“false”部分。
只要写出真实的部分
当你包含虚假的部分时,它会(我认为)考虑到
The simple thing would have been to skip the 'false' section in your IF condition.
Just write the true part
As you included false section, it will (i think) take into account
我们通过更改以下行解决了该问题:
{ 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.