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!

From Access Can't close word session Correctly - Help

Status
Not open for further replies.

newbee2

Technical User
Apr 21, 2002
85
Hi,
I can successfully open a word session and print a document that has 3 pages. Nowever during the execution of the code I get the message
"Word is currently printing. Quitting word will cancel all pending print jobs. Do you want to exit word." YES allows the print but the word session is still active in the "Close programme Window" Choosing no cancels the print.
The code I wrote is

Sub PrintWord()
'Find and open the Word Document with
'the form for printing. It does not
'have to be vissible.
'set up variables for working with Word.

Dim objWord As Word.Application 'Word application Object
Dim objWordDoc As Object 'Word document
'create Word Session

Set objWord = CreateObject("Word.Application")
objWord.Application.Visible = False

'Open relevant file

Set objWordDoc = objWord.Documents.Open("\\Nuconsbs\Sales reg\QUOCHK.doc")
objWordDoc.Activate
objWordDoc.Application.Visible = False

'Print the Document
objWordDoc.PrintOut

'Close the Session
objWordDoc.close wdDoNotSaveChanges
Set objWordDoc = Nothing
objWord.Quit
Set objWord = Nothing

End Sub

If possible where am I going wrong. Thanks in advance.
Regards
Bill
 
Don't let Word Printout method print in the backgound. Wait until output spooled to printer.

Options.PrintBackground = FALSE
OR
Application.PrintOut FileName:="", _
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, _
Copies:=strCopies, _
Pages:="", _
PageType:=wdPrintAllPages, _
Collate:=True, _
Background:=False, _
PrintToFile:=False Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top