[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2006-03-22
15
Medium Priority
?
2,220 Views
Last Modified: 2012-05-05
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?
0
Comment
Question by:mercia
  • 8
  • 6
14 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16256733
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
 

Author Comment

by:mercia
ID: 16256775
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16256942
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
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 

Author Comment

by:mercia
ID: 16257223
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16258868
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
 

Author Comment

by:mercia
ID: 16259112
Thanks for your help, I have tested ideas all afternoon, but with no joy so all help is appreciated.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16260804
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16260822
It will cause omission of the whole record. I'm not sure if that is what you need.
0
 

Author Comment

by:mercia
ID: 16266186
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16266762
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 16266971
I see that you've done some programming. This property should be true

activeDocument.MailMerge.SuppressBlankLines
0
 

Author Comment

by:mercia
ID: 16267056
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
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 1050 total points
ID: 16267598
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
 

Author Comment

by:mercia
ID: 16495574
Thats fine, I agree GrahamSkan has assited me and deserves the points.  Thanks
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question