S
Sandy
I am printing Word 2000 letters and envelopes from an
Access 97 database using Windows NT. To avoid leaving an
instance of Winword running each time I print, I tried
adding "objWord.Quit" to the following code. However, I
keep getting a message that: Word is currently printing,
quitting Word will cancel the print job, do I want to quit
Word? If I say 'yes' the print job is cancelled. If I
say 'no' Winword is left open. Any help would be greatly
appreciated. Thank you.
Sub PrtLetter()
Dim objWord As Object
' Open Microsoft Word using automation
Set objWord = New Word.Application
objWord.Documents.Add gstrTxLetterName, acNormal
objWord.Visible = False
'Pass data from Access to Word document
If objWord.ActiveDocument.Bookmarks.Exists
("PatientName") = True Then
objWord.ActiveDocument.Bookmarks
("PatientName").Range.Text = Me![FirstName] & " " &
[LastName]
End If
'Print the envelope
objWord.ActiveDocument.Envelope.PrintOut
ExtractAddress:=True, OmitReturnAddress _
:=True, PrintBarCode:=False, PrintFIMA:=False,
Height:=InchesToPoints( _
4.13), Width:=InchesToPoints(9.5)
'Print the letter and close Word
objWord.ActiveDocument.PrintOut
objWord.ActiveDocument.Close wdDoNotSaveChanges
objWord.Quit
Set objWord = Nothing
End Sub
Access 97 database using Windows NT. To avoid leaving an
instance of Winword running each time I print, I tried
adding "objWord.Quit" to the following code. However, I
keep getting a message that: Word is currently printing,
quitting Word will cancel the print job, do I want to quit
Word? If I say 'yes' the print job is cancelled. If I
say 'no' Winword is left open. Any help would be greatly
appreciated. Thank you.
Sub PrtLetter()
Dim objWord As Object
' Open Microsoft Word using automation
Set objWord = New Word.Application
objWord.Documents.Add gstrTxLetterName, acNormal
objWord.Visible = False
'Pass data from Access to Word document
If objWord.ActiveDocument.Bookmarks.Exists
("PatientName") = True Then
objWord.ActiveDocument.Bookmarks
("PatientName").Range.Text = Me![FirstName] & " " &
[LastName]
End If
'Print the envelope
objWord.ActiveDocument.Envelope.PrintOut
ExtractAddress:=True, OmitReturnAddress _
:=True, PrintBarCode:=False, PrintFIMA:=False,
Height:=InchesToPoints( _
4.13), Width:=InchesToPoints(9.5)
'Print the letter and close Word
objWord.ActiveDocument.PrintOut
objWord.ActiveDocument.Close wdDoNotSaveChanges
objWord.Quit
Set objWord = Nothing
End Sub