Is there no conditional line print function or variable?

F

FUBARinSFO

Hi:

N00b to Word mail merge here -- apologies in advance.

I'm looking for a conditional line print function -- print/not print
the line as the result of evaluating some expression.

All the solutions I've seen here and elsewhere seem to involve the
chaining of mergefield using the IF statement
(http://www.gmayor.com/formatting_word_fields.htm - "Insert field
information and associated text conditionally") or the code for example
from Graham Major in his posting "Mail Merge and Printing Empty
Fields", shown below:
.....................................................................
Mergefield FirstName} {Mergefield Lastname}
{Mergefield Company}
{Mergefield Address1}
etc

and when Company is empty you get an unwanted blank line. You can then
manually insert your conditional entry on the previous line:

{Mergefield FirstName} {Mergefield Lastname}{IF{Mergefield Company} <>
"" "
{Mergefield Company}"}
{Mergefield Address1}
etc

Press 'enter' after the first " that defines the start of the
conditional
result. Thus if Mergefield Company is not empty (<> "") then the result

places the line feed *and* the Company field. If the mergefield *is*
empty
it does nothing.
..............................................................................

The bug in this chained code is that if the first field is null, but
the second is not, it will print a blank line first and then the second
line field. Aside from that, it is incredibly unreadable to try to
construct a multi-line output using a chained construction like this.

But more generally, what is really needed here is a simple
variable/field that evaluates an expression and either or prints or
suppresses the print of the line that it is on. Isn't that possible?
This chained code is not only wrong, but an incredible hack.

FWIW, I've been using MicroPro InfoStar since around 1983. Its report
writer has the ability to print/not print a line depending on the
evaluation of an expression composed of data record fields. I'm
assuming that Crystal Reports and other database-associated report
writers have this capability. MicroPro's WordStar has it (per my
recollection) -- doesn't Microsoft Word 2003?

TIA

-- Roy Zider
 
P

Peter Jamieson

The bug in this chained code is that if the first field is null, but
the second is not, it will print a blank line first and then the second
line field.

I think you have probably misunderstood what Graham's code is trying to
show. As far as I'm aware it is just trying to show that you can avoid a
blank line for /one/ field by using the construction he suggests. This
particular example isn't trying to show how you can avoid blank lines for
/every/ line where fields are blank.
Aside from that, it is incredibly unreadable to try to
construct a multi-line output using a chained construction like this.

It would of course be nice if we could avoid this kind of construction, but
even the construct which the authors of Word (and the people in this group
do not work for Microsoft and did not write Word) introduced specifically
for Addresses (the ADDRESSBLOCK field ) does not work as well as it might.
So all anyone can do is offer workarounds, and they are (almost) inevitably
less pretty than something which gets the thing right in the first place.
For example, one workaround is to construct the complete address in the data
source, but that's even less likely to be possible for many users, even if
the data source supports it.
But more generally, what is really needed here is a simple
variable/field that evaluates an expression and either or prints or
suppresses the print of the line that it is on. Isn't that possible?

I expect so, but there is no such facility in the current version of Word.
It may be worth e-mailing (e-mail address removed) but I suspect even then
you'll be waiting until the version after Word 2007. A few years ago I
submitted a number of suggestions for improving mailmerge and the "field
language" in general, but Microsoft is obviously driven by commercial
consierations that have led it to invest most of its effort elsewhere
(primarily in XML technology, which I expect is where they'll probably be
looking for any kind of successor to the current "field language").

Some things that you may or may not have picked up so far (I'm not saying
they fix the problem, or even help with the specific problem of suppressing
blank lines, but they are potentially relevant when trying to do stuff in
this general area):
a. Word's default behaviour is already to suppress blank lines that result
from one or more blank MERGEFIELD fields. However in some recent versions of
Word, that doesn't work inside nested fields (e.g. IF or INCLUDETEXT
fields), and there are other complications
b. In Word 2003 the MERGEFIELD field has \b and \f switches that allow text
(and other fields) to be inserted before and after a non-blank. (Not
available for use in other types of field).
c. It is possible to modify the list of fields and the text that Word
inserts in its ADDRESSBLOCK. However,
- it is clearly not Microsoft's intention that users should do this
- the "field" names used by ADDRESSBLOCK are undocumented
- if you ever use the ADDRESSBLOCK edit dialog, any manual changes are
lost
MicroPro's WordStar has it (per my recollection)

:) Can't remember myself (we used WordStar from back in the CP/M days until
about version 5.5 or 6, and pushed it to the limits in some areas). But I
wouldn't personally say that WordStar's dot commands and merge variable
syntax was readable or particularly easy to use either.

Peter Jamieson
 
F

FUBARinSFO

Peter:

Thank you so much for your extended and comprehensive reply. That was
exactly what I was looking for -- not only a confirmation of the
workaround for suppressing the printing of blank lines, but some
perspective on Word's Mail Merge functionality in general.

I did subsequently discover the \f switch for MERGFIELD, which has the
intended effect (for what appears to be single-variable lines with no
other text on them).

I just checked Wordstar, and my recollection was correct: .if, .ei, .el
commands allow for conditional print -- very simple and
straightforward. Word in comparison, in so many ways, is such a hack.
It probably needs a complete rewrite.

Thank you again for your thoughtful reply.

-- Roy Zider
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top