Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing Word from Access

Status
Not open for further replies.

brandnew

Technical User
Dec 7, 2001
1
GB
Hi

I have the following module called 'MergeIt'
it works great, except that it doesn't quit Microsoft Word, with no save prompt as I'd like it too. I've tried loads of things such as objWord.Quit etc, nothing works!!!
The new document it creates is called Labels1
Is this causing the problem?
Any help much appreciated
Steph

Code:
Function MergeIt()
 
         Dim objWord As Word.Document
         Set objWord = GetObject("\\berlin\labels.doc", "Word.Document")
         objWord.Application.Visible = True
         objWord.MailMerge.OpenDataSource _
            name:="\\berlin" & _
          "\test.mdb", _
            LinkToSource:=True, _
            Connection:="QUERY labels", _
            SQLStatement:="Select * from [Table1]"
         objWord.MailMerge.Destination = wdSendToNewDocument
       objWord.MailMerge.Execute
        objWord.Application.Options.PrintBackground = False
        objWord.Application.ActiveDocument.PrintOut
        'objWD.Quit
        
        MsgBox "Mail merge successful", vbInformation, "Mail Merge"
      End Function

 
Yeah thats exactly what I thought would work but it doesn't
I've added

Code:
objWord.Application.ActiveDocument.close False
which closes the created document 'Labels1'
but then word is still open.
I think I need to try and close the Word document which is what objword is set to
 
you added it before the "quit application", i presume.
then:

set objWordApp = objWord.Application
objWord.Application.ActiveDocument.close False
objWordApp.Quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top