Reply
 
Thread Tools Display Modes
  #1   Report Post  
Daniel
 
Posts: n/a
Default If...then...else... NEXT PAGE

Hi,

I am doing up a basic invoicing run from a excel spreadsheet and merging it
with a word document. some clients might purchase more then once that
month... how do i keep the merge happing until a new customer is selected
from the spreadsheet.

so
while [customerNumber] = [LastCustomerNumber]
'add details
else NEXT PAGE

Any help would be great.
Cheers
Daniel.


  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

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/cindy...r/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.

' 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
"Daniel" wrote in message
...
Hi,

I am doing up a basic invoicing run from a excel spreadsheet and merging
it
with a word document. some clients might purchase more then once that
month... how do i keep the merge happing until a new customer is selected
from the spreadsheet.

so
while [customerNumber] = [LastCustomerNumber]
'add details
else NEXT PAGE

Any help would be great.
Cheers
Daniel.




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retaining Section Break at the Bottom of Page 1 Diane M Formatting Long Documents 3 January 14th 05 08:16 PM
Printing and Folding a 40 Page Booklet in WORD 2003 Laura Glazer Page Layout 6 January 6th 05 07:41 PM
Odd page section break Jenny Page Layout 5 December 15th 04 08:05 AM
Need help "fooling" Word with Page Numbering jdkelley Microsoft Word Help 1 December 13th 04 10:26 PM
Unchecking 'different first page' in header removes graphic from first page Denise Page Layout 4 November 26th 04 11:36 AM


All times are GMT +1. The time now is 12:10 PM.

Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright 2004-2023 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"