how to avoid redundancy for: Mail Merge to Create a List

M

Michael Lehmann

http://support.microsoft.com/default.aspx?scid=211303

{ If { MERGESEQ } = "1" "xxxxx { MERGEFIELD City }" ""}<ENTER>
{ SET Place1 { MERGEFIELD City }}<ENTER>
{ If { Place2 } <> { Place1 }"<ENTER>
----------------------------Page Break--------------------------------
xxxxx { MERGEFIELD City }<ENTER>
<ENTER>
yyyyy { MERGEFIELD Employee }{ MERGEFIELD Sales }" "yyyyy { MERGEFIELD
Employee }{ MERGEFIELD Sales }" }{ SET Place2 { MERGEFIELD City
}}<ENTER>

I have inserted xxxxx and yyyyy to show you that there is redundant
information. That is bad programming style. This isn't just a
theoretical problem. In my use there is text with layout for x and y.
It is annoying and error prone to handle these twice.

To avoid the redundany for y, just put it out of the IF.

{ If { MERGESEQ } = "1" "xxxxx { MERGEFIELD City }" ""}<ENTER>
{ SET Place1 { MERGEFIELD City }}<ENTER>
{ If { Place2 } <> { Place1 }"<ENTER>
----------------------------Page Break--------------------------------
xxxxx { MERGEFIELD City }<ENTER>
<ENTER>
" "" }
yyyyy { MERGEFIELD Employee }{ MERGEFIELD Sales }{ SET Place2 {
MERGEFIELD City }}<ENTER>

How can I avoid the redundancy for x? At the start the varaible Place2
is not bound. Which if-clause can handle this?

Why isn't this handled in the catalog function itsself. Just let the
user choose the field (one or more) for the category, no programming,
he just use the fields as an ordinary mail merge.

BTW: There is a bug in comparing. If Place1 and Place2 are both text
starting with the same number but different text afterwards, the if
treats them as equal. My workaround is:
SET Place1 "a{ MERGEFIELD City }" and for Place2 later the same.
 
C

Cindy M -WordMVP-

Hi Michael,
How can I avoid the redundancy for x? At the start the varaible Place2
is not bound. Which if-clause can handle this?
Well, something like this could work, but notice that you then don't
have much control over the document formatting. If, for example, I
want an extra space between each list and the list heading (city, in
your example), I'm in trouble if I don't also want this at the top of
the list.

{ If { MergeRec } = 1 "{ Set Cat2 " " }" "" }{ Set Cat1 "{ MERGEFIELD
"CategoryName" }" }{ If "{ Cat1 }" <> "{ Cat2 }" "AAA-{ MERGEFIELD
"CategoryName" }" "" } { MERGEFIELD "ProductName" }{ Set Cat2 "{
MERGEFIELD "CategoryName" }" }
Why isn't this handled in the catalog function itsself. Just let the
user choose the field (one or more) for the category, no programming,
he just use the fields as an ordinary mail merge.
It would certainly be nice, wouldn't it :) I believe there's a "wish"
page on the microsoft.com website where you could add your vote to the
many that have asked for this, over the last decade.
BTW: There is a bug in comparing. If Place1 and Place2 are both text
starting with the same number but different text afterwards, the if
treats them as equal. My workaround is:
SET Place1 "a{ MERGEFIELD City }" and for Place2 later the same.
Less a bug than just knowing that this is how Word handles numbers;
very idiosyncratic in that respect. Place both sides of the comparison
in "quotes" to tell Word you expect it to look at the content purely
as text.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
M

Michael Lehmann

Hi Cindy,

many many thanks for your fast reply. I got your example working. And
I am glad with the result.
Well, something like this could work, but notice that you then don't
have much control over the document formatting. If, for example, I
want an extra space between each list and the list heading (city, in
your example), I'm in trouble if I don't also want this at the top of
the list.

Yes, but this is normaly a minor problem. In my case I want each
category started on a page. To avoid the first empty page, I format
the paragraph with "page break above" (I do not know the correct
american phrase).
Less a bug than just knowing that this is how Word handles numbers;
very idiosyncratic in that respect. Place both sides of the comparison
in "quotes" to tell Word you expect it to look at the content purely
as text.

I tried it with "{ MERGEFIELD City }" only, but it didn't work. I need
the variable set with a starting char - 'a' in my example.

Can you give me another hint? My record is set in a table row. Each
text category ends with a table header.

{If "{Cat1}" <> "{Cat2}" "{MERGEFIELD "CategoryName"}" ""}
{MERGEFIELD "ProductName"}

{MERGEFIELD "CategoryName"} ends with the table header.
{MERGEFIELD "ProductName"} is a table row.
Between these two I need a paragraph sign, otherwise these two tables
are merged in one and the if statement is corrupt. In my result all
rows have a paragraph sign between them. My workaround is: changing
the font size to 1 and setting it invisible for the paragraph. Do you
have a better way to devide these two tables?
 
C

Cindy M -WordMVP-

Hi Michael,
To avoid the first empty page, I format
the paragraph with "page break above" (I do not know the correct
american phrase).
Just for the sake of thorougness :) "Page break before"
Can you give me another hint? My record is set in a table row. Each
text category ends with a table header.

{If "{Cat1}" <> "{Cat2}" "{MERGEFIELD "CategoryName"}" ""}
{MERGEFIELD "ProductName"}

{MERGEFIELD "CategoryName"} ends with the table header.
{MERGEFIELD "ProductName"} is a table row.
Between these two I need a paragraph sign, otherwise these two tables
are merged in one and the if statement is corrupt. In my result all
rows have a paragraph sign between them. My workaround is: changing
the font size to 1 and setting it invisible for the paragraph. Do you
have a better way to devide these two tables?
You've lost me, here. Willst Du das Problem auf Deutsch beschreiben?
Vielleicht kommt es so besser durch :) Probierst Du mit den IF
Feldfunktionen eine "echte" Tabelle zu erstellen? Oder meinst Du mit
Tabelle nur die Datenquelle? Oder ist die Tabelle gar Teil der Daten
(kann ich mir eigentlich nicht vorstellen...)?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
M

Michael Lehmann

Between these two I need a paragraph sign, otherwise these two tables
You've lost me, here. Willst Du das Problem auf Deutsch beschreiben?
Vielleicht kommt es so besser durch :) Probierst Du mit den IF
Feldfunktionen eine "echte" Tabelle zu erstellen? Oder meinst Du mit
Tabelle nur die Datenquelle? Oder ist die Tabelle gar Teil der Daten
(kann ich mir eigentlich nicht vorstellen...)?

I meant winword tables. How can I stop winword merging two tables in
one, without having a paragraph-sign between them.

Im If ist eine Winword Tabelle und nach dem IF kommt auch eine (Ich
rede hier vom "Hauptdokument"). Die erste soll als Überschrift dienen,
die zweite als Zeile für die Datensätze. Wenn ich den Absatz
dazwischen entferne, zieht Word beide Tabellen zusammen zu einer und
somit ist das if nicht mehr richtig. Den Absatz will ich nicht haben,
denn der zusammengeführte Katlog soll später die Zeilen hintereinander
haben.

Also I have the problem, that word crashes. I have posted this in an
extra thread. There is an example for the crash and for this table
problem also. Many thanks for your help so far.

The example is in the thread:
crash after mail merge

I do not know how to link the post properly, couldn't find a hint, I
post the google link I have trimmed:
http://groups.google.com/groups?th=bb0c87ebee2992d4
 

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