Hi guys!
I'm creating a mailer and I'm pulling the data in from a Microsoft Excel
file into a Word file.
Now, the problem is, there's four address columns. As you'd expect, some
have values, other don't.
So when I put this into Word, I get blank lines between some of the records.
For example, where a record only has one address field, there's a three line
gap between the address and the town.
How do I tell Word to not render the the spare lines? Or more specifically,
tell Word to not render empty data fields?
Thanks!

Signature
wayne smallman., managing director
w: http://www.octane.uk.net
Elliott Roper - 26 Oct 2005 13:47 GMT
> Hi guys!
>
> I'm creating a mailer and I'm pulling the data in from a Microsoft Excel
> file into a Word file.
<snip>
> How do I tell Word to not render the the spare lines? Or more specifically,
> tell Word to not render empty data fields?
One method is to use a heap of nested conditional expressions like this:
{ IF { MERGEFIELD surname } <> "" "{MERGEFIELD title } {
MERGEFIELD initials } { MERGEFIELD surname }
" ""}{ IF { MERGEFIELD position } <> "" "{MERGEFIELD postion }
" ""}{ IF { MERGEFIELD a1 } <> "" " { MERGEFIELD a1}
" ""}{ IF { MERGEFIELD a2 } <> "" " { MERGEFIELD a2}
" ""}{ IF { MERGEFIELD a3 } <> "" " { MERGEFIELD a3}
" ""}{ IF { MERGEFIELD a4 } <> "" " { MERGEFIELD a4}
" ""}{ IF { MERGEFIELD postcode } <> "" " { MERGEFIELD postcode}
} " ""}
where, as you probably guessed, surname initials a1..a4 postcode are
the column headings in the Excel spreadsheet full of names and
addresses. The basic trick is to test if there is anything in the next
excel column, and sneak off to the next IF if not. The line endings are
only output if there had been something to say.
It has worked really well for me. I can afford to be as slack as can be
about smearing someone's name and address all over the spreadsheet
columns.
When doing mailers, I populate extra columns in excel so the data merge
query options can be used to select the recipients. e.g If
gullible_sucker is equal to "y" (only joking, honest!)
You might need to debug this, I might have missed the odd space and }
as I excerpted it from my own letterhead template which is even more
baroque than the above. The line endings and spaces are pretty
critical. Not for the faint-hearted, but it has worked for me ever
since Word v 5.1 which had a much cleaner field facility than the
current pile of bloat. I remember fighting tooth and nail with the
'wizards' that wanted to 'help' me when I moved it to Word X. I
honestly can't remember how I forced it in there in the end. I think I
had to type it all in again after somehow tricking the 'wizard' into
showing me its version of the mergefield structure. Option-f9 is a
useful keystroke sequence. It toggles between field commands and their
output. If this is all a mystery, curl up with the help system and ask
it about fields. Expect to be gone for some time.
Why oh why does MS call those things 'wizards'. To the best of my
knowledge, most Americans do not admit to understanding the meaning of
irony.
If it were me, I'd call them sorcerer's apprentices and play, as a
warning, Dukas' music any time one of them has focus.
Hat der alte Hexenmeister
Sich doch einmal wegbegeben!
Und nun sollen seine Geister
Auch nach meinem Willen leben.
Seine Wort und Werke
Merkt ich und den Brauch,
Und mit Geistesstärke
Tu ich Wunder auch.
(That's for Clive. We gotta keep our literary allusions flying)

Signature
To de-mung my e-mail address:- fsnospam$elliott$$
PGP Fingerprint: 1A96 3CF7 637F 896B C810 E199 7E5C A9E4 8E59 E248
wayne smallman - 27 Oct 2005 09:41 GMT
On 26/10/05 1:47 pm, in article 261020051347140115%nospam@yrl.co.uk,
>> Hi guys!
>>
[quoted text clipped - 61 lines]
>
> (That's for Clive. We gotta keep our literary allusions flying)
Hi Elliott!
Thanks for that.
There's a lot in there for me to work through, but I'm sure I'll make sense
of it.
I did try just merging columns in Excel, but Excel chooses to do that in a
destructive manner and not by actually appending the data in each column.
Thanks again!

Signature
wayne smallman., managing director
w: http://www.octane.uk.net
Elliott Roper - 27 Oct 2005 13:03 GMT
> Hi Elliott!
>
[quoted text clipped - 5 lines]
> I did try just merging columns in Excel, but Excel chooses to do that in a
> destructive manner and not by actually appending the data in each column.
No, you need to be looking at Tools -> Data merge manager in Word and
using your spreadsheet as the data source mentioned in there. It is a
very useful and powerful technique for mailshots and anything else that
makes good use of all the grunt in Excel.
Merging the contents of two columns in Excel is another whole can of
worms. hint: text functions. But you don't need any of that for this
job unless you want to clean up your spreadsheet first.

Signature
To de-mung my e-mail address:- fsnospam$elliott$$
PGP Fingerprint: 1A96 3CF7 637F 896B C810 E199 7E5C A9E4 8E59 E248
JosypenkoMJ@Npt.NUWC.Navy.Mil - 28 Oct 2005 02:23 GMT
> Hi guys!
>
[quoted text clipped - 16 lines]
> wayne smallman., managing director
> w: http://www.octane.uk.net
This can be done with a simple text editor such as MPW or BBEdit, OS
9.__ or earlier (not sure what there is in OS 10._.) :
- copy the cells from Excel and paste into, eg. MPW. The fields will be
separated by TAB characters.
- where there is a blank field, there will be 2 sequential TAB's. These
can be more easilly seen by turning "Show invisibles" on. Copy the 2
sequential TAB's.
- under Find/Replace, paste the 2 TAB's into the find string. Set the
replace string to1 TAB.
- put cursor at top of window
- Hit "Replace All". All occurances of 2 sequential TAB's will be
replaced with 1 tab and thus one blank field / row will be removed.
- repeat previous 2 steps until all double TAB's are removed
- copy and paste the fixed test into Word. All fields will be separated
with TAB's.
- or if the text is to be in a table, copy and paste the fixed test
into a Word table of size maximum number of columns and maximum number
of rows of the text.
Or the multiple tabs can be removed with a simple Fortran program.
JosypenkoMJ@Npt.NUWC.Navy.Mil - 29 Oct 2005 20:08 GMT
> > Hi guys!
> >
[quoted text clipped - 38 lines]
>
> Or the multiple tabs can be removed with a simple Fortran program.
I made a large oversight - Word itself can be used as a simple text
editor. Thus to remove blank fields from an Excel sheet :
- copy the cells from Excel and paste special into Word as unformatted
text. The fields will be separated by TAB characters.
- where there is a blank field, there will be 2 sequential TAB's. Copy
a TAB.
- under Edit/Replace, paste 2 TAB's into the find string, and1 TAB in
the replace string. Word will echo a tab as ^t, and ^t can be typed for
a tab instead.
- put cursor at top of window
- Hit "Replace All". All occurances of 2 sequential TAB's will be
replaced with 1 tab and thus one blank field / row will be removed.
- repeat previous 2 steps until all double TAB's are removed
- now all blank fields are removed. Fields will be separated by single
TAB's.
- if the text is to be in a table, copy and paste the fixed text into
a Word table of size maximum number of columns and maximum number of
rows of the text.
- or copy and paste the fixed text into Excel.
Matt Centurión [MSFT] - 28 Oct 2005 22:08 GMT
On 10/26/05 4:36 AM, in article BF8528C2.4506%info@octane.uk.net, "wayne
smallman" <info@octane.uk.net> wrote:
> Hi guys!
>
[quoted text clipped - 13 lines]
>
> Thanks!
Hey Wayne,
Word by default will not include blank merge fields. If an entire line is
blank then Word Data Merge will remove the entire line.
Check your XL sheet to make sure you accidentally don't have "spaces" in
the blank fields. If any of these fields in XL have white space, then Word
will include the line.
Matt
MacWord Testing
Microsoft

Signature
This posting is provided "AS IS" with no warranties, and confers no rights.
MS Mac Newsgroups: http://www.microsoft.com/mac/support/newsgroups.asp
MS Mac News & Updates: http://www.microsoft.com/mac