Closing Word using Automation

R

richardb

My Access database controls a Mail Merge Job in Word. After generating the
data, Access opens the Word document with these lines of code in a module:

Set objWord = GetObject("G:\Access Projects\MyWordDoc.doc", "Word.Document")
objWord.Application.Visible = True
objWord.RunAutoMacro wdAutoOpen

In the Word document the Sub AutoOpen Prints the mail merge job. My AutoOpen
code ends with ActiveDocument.Close wdDoNotSaveChanges. Unfortunately, all
this does is to close the document. What I want is to completely close out
Word and return my screen to Access where I left off. I have searched, but
can't figure out how to do this. Would appreciate assistance.
 
G

Gina

Try

Application.Quit SaveChanges:=False
maybe in AutoExit() - may not be done in the Close event ....

cheers,
Gina
 
J

Jonathan West

richardb said:
My Access database controls a Mail Merge Job in Word. After generating the
data, Access opens the Word document with these lines of code in a module:

Set objWord = GetObject("G:\Access Projects\MyWordDoc.doc",
"Word.Document")
objWord.Application.Visible = True
objWord.RunAutoMacro wdAutoOpen

In the Word document the Sub AutoOpen Prints the mail merge job. My
AutoOpen
code ends with ActiveDocument.Close wdDoNotSaveChanges. Unfortunately, all
this does is to close the document. What I want is to completely close out
Word and return my screen to Access where I left off. I have searched, but
can't figure out how to do this. Would appreciate assistance.

Take a look here


Control Word from Excel
http://www.word.mvps.org/FAQs/InterDev/ControlWordFromXL.htm


The same principles apply to controlling Word from Access


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
R

richardb

Hi Jonathan,

That was very helpful, but I still cannot restore Access as the Active
(i.e., visible [in case "Active" is the wrong term]) application after I
close the word document. Access remains minimized. Advice appreciated...thank
you...
 
J

Jonathan West

Hi Richard

Since you are working in Access and trying to change the activated status of
the Access application, you will have a better chance of getting an
authoritative answer from one of the Access programming newsgroups.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

richardb said:
Hi Jonathan,

That was very helpful, but I still cannot restore Access as the Active
(i.e., visible [in case "Active" is the wrong term]) application after I
close the word document. Access remains minimized. Advice
appreciated...thank
you...

Jonathan West said:
Take a look here


Control Word from Excel
http://www.word.mvps.org/FAQs/InterDev/ControlWordFromXL.htm


The same principles apply to controlling Word from Access


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
T

Tony Jollans

When Word has finished running its stuff - you can close Word from Access
with

objWord.Quit
Set objWord = Nothing
 

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