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
--
Message posted from http://www.ExcelForum.com
Doug Robbins - 24 Sep 2004 10:10 GMT
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

Signature
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
> Hi
>
[quoted text clipped - 23 lines]
> ---
> Message posted from http://www.ExcelForum.com/