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 / April 2005

Tip: Looking for answers? Try searching our database.

VBA & Mail merges

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Clarkie - 11 Apr 2005 14:31 GMT
I have a userform with vba macro's in it, but when I
perform a mail merge and save the results as a new
document, the macro's have been lost.

Is there any way round this ?
Cindy M  -WordMVP- - 12 Apr 2005 15:58 GMT
Hi Clarkie,

> I have a userform with vba macro's in it, but when I
> perform a mail merge and save the results as a new
> document, the macro's have been lost.
>  
> Is there any way round this ?

Use a macro to execute the mailmerge to a new document.
After the .execute command, put in a code line to attach
the template to the document. Roughly:
   ActiveDocument.AttachedTemplate = "the path"
or, pick it up from the main merge document
   Dim mergeDoc as Word.Document

   Set mergeDoc = ActiveDocument
   mergeDoc.MailMerge.Execute
   ActiveDocument.AttachedTemplate =
mergeDoc.AttachedTemplate

(Note: all off the top of my head, so there may be sytax
errors in there. But that's the basic way you have to go.)

Since Word97 or so, mail merge does attach the merge result
doc to the same template as the main merge document. But
somehow the link back to the template is incomplete. so you
need to force the link.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)
 
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.