Access Command to Close and Save a Word Document

G

Guest

Paste this procedure into a module and call it by supplying the full path of
the file you're trying to save and close.

eg) SaveAndCloseWord "c:\myfile.doc"


Sub SaveAndCloseWord(strPath As String)
Dim wapp As Word.Application
Dim wdoc As Word.Document
Set wdoc = GetObject(strPath)
Set wapp = wdoc.Parent
wdoc.Save
wdoc.Close
wapp.Quit
Set wdoc = Nothing
Set wapp = Nothing
End Sub
 

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