Mail Merge problem with Headers

C

Chris

I have a odd problem using Word 2002 VBA

I have a mailmerge document set up as a Directory with merge fields in both
the header and main body of the document
When I automate the mailmerge process the merge works fine with the
exception of the Header records which still have the merge field names
displayed

However when I use the mailmerge wizzard and manually do the merge the
Header has the correct data merged

I duly recorded a macro to see if I was missing a parameter and when I re -
run the recorded macro the Headers do not merge

Can anybody shed any light on this behaviour

Any info very very gratefully recieved
 
P

Peter Jamieson

I've never really got to the bottom of this one, but if I do the following:
a. create a directory type merge using the Mail merge toolbar
b. insert a field from the data source into the body of the document,
followed by an extra paragraph mark
c. copy the field into the header
c. merge to a document

I see the field in its <<fieldname>> form

If I then click the Preview data button (the one that looks like

<< >>
ABC

) and merge again, I see one of the values of fieldname.

Clicking the Preview button is recorded as

ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle

Unclicking again doesn't appear to make the behaviour revert.

If you replay the recording of that lot, you get the same behaviour.

If you record you macro using the mail merge wizard, when you are setting up
the document, the wizard takes you through a task pane where you "preview
the document". It looks to me as if at this point, Word must in effect
execute

ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle

but it does not record it in the macro, so when you play the macro back with
a new document, you see <<fieldname>> rather than the fieldname value.

In any case, be careful when putting merge fields in headers/footers
because, in the general case you may have data from multiple data source
records on the same page: which record should Word take the header/footer
value from?

Also, you may need to look out for yet another quirk: when you merge using
the toolbar or the wizard, Word names the output document "Directoryn",
where n is a sequence number. When you merge using VBA, Word reverts to
using the old name "Catalogn".

Peter Jamieson
 
C

Chris

I see what you mean , that's bizzare but any Fix is much appreciated

I had already spotted the Catalog/Directory name thing

thanks again
 

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