mercia
asked on
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?
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?
ASKER
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?
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)" }
{SkipIF { MERGEFIELD Qty}=0 } { "{MERGEFIELD QTY} copies - VAT zero rate)" }
ASKER
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?
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.
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.
ASKER
Thanks for your help, I have tested ideas all afternoon, but with no joy so all help is appreciated.
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 >>
I've just tested it against a potentially blank field.
I seems to work OK wherever it is positioned.
{ SkipIf << Field1 >> = "" } << Field1 >> << Field2 >>
It will cause omission of the whole record. I'm not sure if that is what you need.
ASKER
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.
{ 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.
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?
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?
I see that you've done some programming. This property should be true
activeDocument.MailMerge.S uppressBla nkLines
activeDocument.MailMerge.S
ASKER
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.
Thanks for all your help.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thats fine, I agree GrahamSkan has assited me and deserves the points. Thanks
The SKIPIF field might suit you.