Close main mailmerge document

A

aprendiz

I have a template marging a document with an SQL database.
When it merges the document it saves to a new document.
I want to have the new document open and close the main mail merge but it seems to be not working it will close the new document and the main one altogether or it will close the new document and will leave open de main one.
Any ideas?
 
D

Doug Robbins - Word MVP

Use something like:

Dim source As Document
Set source = ActiveDocument
If source.MailMerge.State = wdMainAndDataSource Then
With source.MailMerge
.Destination = wdSendToNewDocument
.Execute
End With
source.Close wdDoNotSaveChanges
Else
MsgBox "The active document is either not a mailmerge main document or
does not have a datasource attached."
End If


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
aprendiz said:
I have a template marging a document with an SQL database.
When it merges the document it saves to a new document.
I want to have the new document open and close the main mail merge but it
seems to be not working it will close the new document and the main one
altogether or it will close the new document and will leave open de main
one.
 

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