Mail Merge using trim on an If. . . then function

I have created a mail merge that uses If. . . then to determine if some information should be displayed or not.  This is great but if the condition is not true then I have left the command "".  The problem with this is that the information is being displayed in a table and therefore I end up with blank rows.  I would like to remove these blank rows.  I am hoping that there is some kind of Trim function within Word that I can use.
At the moment the commands look like this:
{IF { MERGEFIELD Qty}>0 " {MERGEFIELD QTY} copies - VAT zero rate)" ""}
{IF { MERGEFIELD Inside_Cover } >0  "Print cover cost - (VAT zero rate)" ""}

Does anyone know if what I want is possible?
merciaAsked:
Who is Participating?
 
GrahamSkanRetiredCommented:
I'm not sure that's right.

The property should be set on the Main document and should only need doing once, and would be saved if the Main document is saved

The usual system for MailMerge is to reuse the Main document, so there is no Document_New Event, which fires when a new document is made from the template.

If you have a template from which you create a new Main document for each run, then you could well put it there.
0
 
GrahamSkanRetiredCommented:
I would think that any Trim function (which in VB removes spaces from each end of a string) would still leave an empty string, and hence an empty row.
The SKIPIF field might suit you.
0
 
merciaAuthor Commented:
Thanks. SKPIF is new to me, I will try it, if you was to apply it to {IF { MERGEFIELD Qty}>0 " {MERGEFIELD QTY} copies - VAT zero rate)" ""} where would you put it?  At the begining of the IF or before it?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
GrahamSkanRetiredCommented:
It's ages since I last used it (Word 6, probably) but I would do something like this, with the emphasis on something.
{SkipIF { MERGEFIELD Qty}=0 } { "{MERGEFIELD QTY} copies - VAT zero rate)" }
0
 
merciaAuthor Commented:
Thanks for the advice, but it did not work is SkipIf used to skip the record or line?  I am now think that it might be n idea to not put each If on a new line and if the condition is found to be true then carridge return then type my text?  In your SkipIF you have the Else part outside the brackets is the deliberate?  I am trying to look up skipif to see its uses.  What do you think about the carridge return idea?
0
 
GrahamSkanRetiredCommented:
It was deliberate, but perhps not well informed. However, the logic was that records with the skip condition met just wouln't be seen in the output at all, so that further nesting would not be necessary.

I'll try to find to to do some tests to remind me exactly how it should work, but it may be a while and you might find the answer before me.
0
 
merciaAuthor Commented:
Thanks for your help, I have tested ideas all afternoon, but with no joy so all help is appreciated.
0
 
GrahamSkanRetiredCommented:
Yes. I was careless There isn't any need for a false part.

I've just tested it against a potentially blank field.
I seems to work OK wherever it is positioned.

{ SkipIf <<  Field1 >> = "" } << Field1 >> << Field2 >>
0
 
GrahamSkanRetiredCommented:
It will cause omission of the whole record. I'm not sure if that is what you need.
0
 
merciaAuthor Commented:
Thanks for the code, but I am looking for Word to not print that line and therefore move itself up.  The best way to describe is like mail merge lables.  When you produce lables and use merge fileds you may have 3 lines for the address { Addr1 }{ Addr2 }{ Addr3 }. If these are placed on the lable in the following format:

{ Addr1 }
{ Addr2 }
{ Addr3 }

If { Addr2 } contains a null then the line is not printed.  You will not end up with an address like:

{ Addr1 }

{ Addr3 }

It will look like

{ Addr1 }
{ Addr3 }
Do you understand what I mean?  I would therefore like to do the same with the If. . . then merged fields.  Hope this makes sense.
0
 
GrahamSkanRetiredCommented:
In Word 2000, there is an opportunity on the 'Merge' dialogue to choose between printing and not printing blank lines.
In Word 2003, this dialogue is not used in the guided process, but the property (SupressBlankLines) is set by default.

What Version of Word are you using and how are you with VBA?
0
 
GrahamSkanRetiredCommented:
I see that you've done some programming. This property should be true

activeDocument.MailMerge.SuppressBlankLines
0
 
merciaAuthor Commented:
That is sounding like the answer I will give it a go.  I am guessing that I would apply this to the master document under Document_New, is that correct?

Thanks for all your help.
0
 
merciaAuthor Commented:
Thats fine, I agree GrahamSkan has assited me and deserves the points.  Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.