Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Closing a template from the autoOpen macro
I have a mailmerge template with the following AutoOpen macro
ActiveDocument.MailMerge.OpenDataSource "C:\MergeData\LevelData.txt" ActiveDocument.MailMerge.Execute I want this template to automatically close when the mailmerge is executed to the new document because I don't want to have to manually close two Word documents after the mailmerge has happened. Is there another line of code that can achieve that? dixie |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Closing a template from the autoOpen macro
Dim maindoc as Document
Set maindoc = ActiveDocument With maindoc .MailMerge.OpenDataSource "C:\MergeData\LevelData.txt" .MailMerge.Execute 'you may want to specify the destination .Close wdDoNotSaveChanges EndWith -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Dixie" wrote in message ... I have a mailmerge template with the following AutoOpen macro ActiveDocument.MailMerge.OpenDataSource "C:\MergeData\LevelData.txt" ActiveDocument.MailMerge.Execute I want this template to automatically close when the mailmerge is executed to the new document because I don't want to have to manually close two Word documents after the mailmerge has happened. Is there another line of code that can achieve that? dixie |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Closing a template from the autoOpen macro
When you merge to a new document, it becomes the Activedocument. So you need
something more like Dim objMainDocument As Word.Document Set objMainDocument = ActiveDocument objMainDocument.MailMerge.OpenDataSource "C:\MergeData\LevelData.txt" objMainDocument.MailMerge.Execute ' if you want to save and close the new document, use something like ActiveDocument.Saveas Filename:="whatever.doc" ActiveDocument.Close Savechanges:=False ' To close the main document... objMainDocument.Close Peter Jamieson "Dixie" wrote in message ... I have a mailmerge template with the following AutoOpen macro ActiveDocument.MailMerge.OpenDataSource "C:\MergeData\LevelData.txt" ActiveDocument.MailMerge.Execute I want this template to automatically close when the mailmerge is executed to the new document because I don't want to have to manually close two Word documents after the mailmerge has happened. Is there another line of code that can achieve that? dixie |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Understanding Macros | Microsoft Word Help | |||
How to I lock a template for modification only? | Microsoft Word Help | |||
How Come? | Mailmerge | |||
Global/Master Template | New Users | |||
Templates | Page Layout |