I've created a program that creates envelopes using word by passing in the recipients name. No matter what I've done, I can not get the program to release the word doc. from the system memory. What ends up happening is there are 13 open word documents when the code completes it's course through the recordset. Here's the applicable section of my code (I've commented out what I've already tried):
Dim appWord As Word.Application
'Set appWord = CreateObject("Word.Application.8")
Set appWord = New Word.Application
sFile = App.Path & "\Envelope.doc"
appWord.Documents.Open sFile
appWord.ActivePrinter = gPrinter
appWord.ActiveDocument.Envelope.PrintOut Address:=recip, _
Size:="Size 10", PrintBarCode:=False
'DoEvents
CleanUp:
appWord.Documents(1).Close Savechanges:=wdDoNotSaveChanges 'master document
If Not appWord Is Nothing Then Set appWord = Nothing
Exit Sub
Any help is greatly appreciated!
Dim appWord As Word.Application
'Set appWord = CreateObject("Word.Application.8")
Set appWord = New Word.Application
sFile = App.Path & "\Envelope.doc"
appWord.Documents.Open sFile
appWord.ActivePrinter = gPrinter
appWord.ActiveDocument.Envelope.PrintOut Address:=recip, _
Size:="Size 10", PrintBarCode:=False
'DoEvents
CleanUp:
appWord.Documents(1).Close Savechanges:=wdDoNotSaveChanges 'master document
If Not appWord Is Nothing Then Set appWord = Nothing
Exit Sub
Any help is greatly appreciated!