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
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