The actual "Merged" Document

P

Preet

Hi

I am trying to reference a merged document, hence I have my macro i
the Template, which merges to a seperate document. I then bring thi
merged document (that can be called anything from "FormLetter1" t
"Letters1") into PRINT PREVIEW format.

From here, the user can choose what they want to do i.e. they can clic
on the "x" or File> Close/Exit, and I want not only the print preview t
close but the merged doc, e.g. Letters2 and then the template, BUT
cannot seem to reference this merged document as its name isnt alway
consistent.

I am able to get the doc in print preview format, and close th
template but as the macro is in the template I cannot close it, but a
awaiting the user to click on File > Exit, and once they do tha
everything will close, with NO CHANGES, i.e. the SAVE AS dialogue bo
shouldnt appear!

I hope someone can help!

Thanx alot!

Preet
 
D

Doug Robbins

Dim maindoc as Document, mergeresult as Document

Set maindoc = ActiveDocument 'before the merge is executed
With maindoc.MailMerge 'etc

' code to execute the merge

End With

'after executing the merge, the result of the merge will be the active
document so use

Set mergeresult as ActiveDocument

' Now you have two document objects defined each of which can be acted upon
independently by reference to either maindoc or mergeresult as appropriate.
e.g.

maindoc.Close wdDoNotSaveChanges

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 

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