Need code to remove original instance of Mail-Merge doc

G

Gary Escher

I am opening a WORD mail merge document (catalog) from
ACCESS 2000. It transfers and opens a new document (Form
1) properly, but when I close it to return to ACCESS the
original instance is still visible.

I need code in ACCESS to close the original document after
the mail merge is completed. HELP
 
P

Peter Jamieson

Presumably you are doing something like the following in Access (this is
pseudocode, not real VBA):

set wordapp = getobject(Word.Application)
if there's an error, set wordapp = createobject(Word.Application)
set mmmd = wordapp.Open("the pathname of the mail merge main document")
mmmd.MailMerge.Execute

' At this point, wordapp.Activedocument should be the output document

So what I think you need to do is

wordapp.Activedocument.close

mmmd.close
set mmmd = nothing
wordapp.quit
set wordapp = nothing

In other words, as long as you are using unambiguous names to refer to the
objects you are creating, you should be able to close everything cleanly.

Or are you experiencing something else altogether/
 

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