#1   Report Post  
Nuyttens Xavier
 
Posts: n/a
Default Merge catalog

Hi,

I wrote a program that uses Word (through automation) for making letters and
catalogs, but I have a problem when I want to make a catalog that has some
fixed data on top (like titels etc.) : Word keeps repeating them for every
record. One option to solve it is to put the fixed data (which contains
fields also) in the header, but I'm not completely satisfied with this one,
is there a better (easier) way to do this, keeping in mind that everything
has to be transparant to the user (all the work has to be done through
automation).

thanks in advance
Xavier, CPS


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

The only other option is to use a label type mailmerge, but that requires
that you set up the whole page with mergefields and Next Record fields
in the appropriate places.

I suspect that what you may however by trying to do is a one to many
mailmerge.

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
"Nuyttens Xavier" wrote in message
...
Hi,

I wrote a program that uses Word (through automation) for making letters
and catalogs, but I have a problem when I want to make a catalog that has
some fixed data on top (like titels etc.) : Word keeps repeating them for
every record. One option to solve it is to put the fixed data (which
contains fields also) in the header, but I'm not completely satisfied with
this one, is there a better (easier) way to do this, keeping in mind that
everything has to be transparant to the user (all the work has to be done
through automation).

thanks in advance
Xavier, CPS



  #3   Report Post  
Peter Jamieson
 
Posts: n/a
Default

If you are using Word 2002 or 2003 and you are allowed to put macros in the
Mail merge main document or attached template, you could consider using
mailmerge events - trap the MailMergeBeforeRecordMerge event and, after the
first record hass been merged, delete the header material from the mail
merge main document. You will probably need to ensure that the user does not
save the modified document after the merge.

For example, in the typical case where you have a single table row
containing the fields to be merged and a single header row that should only
appear at the beginning,
a. create the table, insert your header texts and mergefeilds, and insert a
bookmark called "bmheader" anywhere in the header row
b. in VBE, create an ordinary module called AutoMacros and put the
following in it

Dim X As New EventClassModule
Sub AutoOpen()
Set X.MyApp = Word.Application
End Sub

c. in VBE, create a Class Module called EventClassModule and put the
following in it:

Public WithEvents MyApp As Word.Application

Private Sub MyApp_MailMergeAfterRecordMerge(ByVal Doc As Document)
If Doc.Bookmarks.Exists("bmheader") Then
' delete the first table row, thereby deleting the bookmark
Doc.Tables(1).Rows(1).Delete
End If
End Sub

Save the document, open it, and merge to a new document.

Peter Jamieson


"Nuyttens Xavier" wrote in message
...
Hi,

I wrote a program that uses Word (through automation) for making letters
and catalogs, but I have a problem when I want to make a catalog that has
some fixed data on top (like titels etc.) : Word keeps repeating them for
every record. One option to solve it is to put the fixed data (which
contains fields also) in the header, but I'm not completely satisfied with
this one, is there a better (easier) way to do this, keeping in mind that
everything has to be transparant to the user (all the work has to be done
through automation).

thanks in advance
Xavier, CPS



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
mail merge with attachments AS Mailmerge 5 April 9th 05 09:49 AM
Can I reset the record pointer in a catalog merge document? AIngersoll Mailmerge 3 January 27th 05 06:03 AM
Can you create a multi-layered merge where certain merge fields a. mileszat Mailmerge 3 January 18th 05 03:46 AM
Home Phone field not getting picked up in Merge Cathleen McGuire Mailmerge 4 January 7th 05 03:13 AM
stripping commas from merge data Patrick Heilman Mailmerge 0 December 30th 04 04:09 AM


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

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

About Us

"It's about Microsoft Word"