Thread: Merge catalog
View Single Post
  #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