Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

Mail Merge problem with Headers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 27 Oct 2006 09:58 GMT
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
Peter Jamieson - 27 Oct 2006 15:36 GMT
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

>I have a odd problem using Word 2002 VBA
>
[quoted text clipped - 15 lines]
>
> Any info very very gratefully recieved
Chris - 27 Oct 2006 15:53 GMT
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

> 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
[quoted text clipped - 61 lines]
> >
> > Any info very very gratefully recieved

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.