Mailmerge leaves out blanks at the start/end of mergefields

C

Claus Persson

I have a mailmerge with 4 fields like this:
«G1»«G2»«G3»«G4»

My problem is that if a field end/starts with at blank it is left out ->
missing blank between two words

Here is a test merge where there should be a blank between G1-G2, G2-G3 and
G3-G4:
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8
9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
5 6 7 8 9 0 1 2 3 4 5 6 7 8<Missing blank>9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
6<Missing blank>7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2
3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4<Missing blank>5 6 7 8 9 0 1 2 3
4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
8 9 0 1 23

Can anyone solve my problem.

Thanks in advance

Claus Persson
 
P

Peter Jamieson

Yes, whether Word leaves out spaces at the beginning or end of the field or
both depends on the data source and how you connect to it. It probably even
depends on the version of Word, but 2003 (say) and 2007 seem close.

For example,
a. if you connect to a comma-delimited .txt file using ODBC or OLE DB, Word
will drop leading and trailing spaces
b. if you connect to the same file but using Word's internal text
converter, word will drop leading spaces if the texts are not surrounded by
quotes
c. if you connect to the same file but using Word's internal text
converter, word will retain both leading and trailing spaces if the texts
are surrounded by quotes
d. if you open that file and save it as a Word .doc file, the behaviour is
pretty much the same as (b) and (c) AFAICR.
....and so on.

If you want to ensure that there is always a blank between those 4 fields,
you could try using IF statements with wildcards to insert space where there
is none and to avoid inseerting space where there is already one, e.g.

{ MERGEFIELD G1 }{ SET S1 " " }{ IF "{ MERGEFIELD G1 }" = "* " "{ SET S1
"" }" "{ IF "{ MERGEFIELD G2 }" = " *" "{ SET S1 "" }" "" }"
}{ S1 }{ MERGEFIELD G2 }{ SET S2 " "...etc


(I haven't tested it, but another thing you have to take into account is
that comparisons only take account of the first so many characters of the
firld - 127 or some such).
 

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