next-record-if else STOP?

D

David Rothman

simple application, nothing fancy, but not sure how to do this...

i have an array of names/addresses sorted by group in excel with a field of
0's and 1's acting as a flag denoting whether a new group should start
(bunch of zero's followed by a single 1 to indicate new group)

i also have a table (with form fields) in Word that i want to use to
generate an email such that the table gets repeated (with the info from
excel) for each

for example:

0, john smith, 123 main st, ny, NY
0, mary jones, 235 broadway, pitts, pa
1, bob johnson, 12 state st, phila, pa
0, andy chin, 100 libert st, hoboken,nj
0, ...
0, ...
0, ...
1, ...
0,...
1,..

all i want to do is:

print the form 3 times for group 1 => and then email it
print the form 5 times for next group => and then email it
print the form 2 times for next group => and then email it

max number of people in a group is 10, so i could replicate the table 10
times and use 'next-record-if' (if flag = 0) between each table, but word
doesn't know when to 'stop', so it repeats that last record until 10 forms
are written out.

i really want a loop and some sort of an 'exit' command.

i'm sure this is easy in VB, but is there a way to get a similar result w/o
fully blown VB programming? the Word fields seem to be awfully limiting
when accessed thru the mail-merge toolbar, so i'm hoping there's something
in there that i'm not seeing. thanks.
 
D

David Rothman

105888 seemed more difficult than 294686.

what i don't understand in 294686 is why i'm getting page breaks between
each line of output. the example in the KB indicates just linefeeds, yet i
can't get rid of the section (page breaks).

thanks for any help.

p.s. is there a way to cut and paste those control codes?
 
C

Cindy M -WordMVP-

Hi David,
what i don't understand in 294686 is why i'm getting page breaks between
each line of output. the example in the KB indicates just linefeeds, yet i
can't get rid of the section (page breaks).
Are you choosing a catalog (directory) type of mail merge? That's the only
one that doesn't insert a next page section break after each record.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 
D

David Rothman

ok..great thanks..that works...

now :)-) )...

using the 294686 analogy, i now have a document with a Heading ("City") and
a bunch of data points under it and that repeats, ala:

Houston
record1
record2
record3

Atlanta
record1

NY
record1
record2
record3
record4
etc etc


i can put delimeters before each city name (ie. City: Houston).

i could even put a section or page break.

but, is there a relatively simple way to send an email to the email address
associated with each city where it would contain (just) that city's data?

or worst case, is there a simple Word file splitter around that could split
the word file into named (i..e Atlanta.doc) files so that i could manually
email them? thanks again
 
D

Doug Robbins

Word does not really have the ability to perform a "multiple items per
condition (=key field)" mailmerge.

See the "Multiple items per condition" item under the "Special merges"
section of fellow MVP CIndy Meister's website at

http://homepage.swissonline.ch/cindymeister/MergFram.htm

Or, if you create a Catalog (on in Word XP and later, it's called Directory)
type mailmerge main document with the mergefields in the cells of a one row
table in the mailmerge main document with the keyfield in the first cell in
the row and then execute that merge to a new document and then run the
following macro, it will create separate tables with the records for each
key field in them. With a bit of further development, you may be able to
get it to do what you want - like put each of those tables in a separate
document and email them.

See the article "Mail Merge to E-mail with Attachments" at

http://word.mvps.org/FAQs/MailMerge/MergeWithAttachments.htm

' Macro to create multiple items per condition in separate tables from a
directory type mailmerge

Dim source As Document, target As Document, scat As Range, tcat As Range
Dim data As Range, stab As Table, ttab As Table
Dim i As Long, j As Long, k As Long, n As Long
Set source = ActiveDocument
Set target = Documents.Add
Set stab = source.Tables(1)
k = stab.Columns.Count
Set ttab = target.Tables.Add(Range:=Selection.Range, numrows:=1,
numcolumns:=k - 1)
Set scat = stab.Cell(1, 1).Range
scat.End = scat.End - 1
ttab.Cell(1, 1).Range = scat
j = ttab.Rows.Count
For i = 1 To stab.Rows.Count
Set tcat = ttab.Cell(j, 1).Range
tcat.End = tcat.End - 1
Set scat = stab.Cell(i, 1).Range
scat.End = scat.End - 1
If scat <> tcat Then
ttab.Rows.Add
j = ttab.Rows.Count
ttab.Cell(j, 1).Range = scat
ttab.Cell(j, 1).Range.Paragraphs(1).PageBreakBefore = True
ttab.Rows.Add
ttab.Cell(j + 1, 1).Range.Paragraphs(1).PageBreakBefore = False
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
Else
ttab.Rows.Add
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
End If
Next i


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
D

David Rothman

doug, i don't think i was clear...

the RESULT of my mail merge (using 294686) was something like:

City:Houston
email:[email protected]

record1
record2
record3

City: Atlanta
email:[email protected]

record1

City:NY
email:[email protected]

record1
record2
record3
record4



some of the lists had 50-100 records (thus if paged, they would run to more
than one page).

my 'simple' task now is to strip out Atlanta's records and email to
(e-mail address removed)
and similarly to every city.

i could use a word keystroke macro to do most of it (search on "City:" cut
that section out of the main doc and paste to a new doc, but when i get to
emailing, the macro stops (as you're no longer in Word's domain, but in your
email client's), but i can't automate the whole process.

i was hoping there's a macro floating around that could parse a Word file
into sections and email them according to some email address field per
section. thanks for any ideas.
 
D

Doug Robbins

Hi David,

I don't know of one floating around that does exactly what you want, but
using some of the ideas/methods in what I previously posted and some of the
techniques in the article "Mail Merge to E-mail with Attachments" at

http://word.mvps.org/FAQs/MailMerge/MergeWithAttachments.htm

you should be able to achieve it.
--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 

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