Add a reference to 'Microsoft Word 9.0 Object Library'
I'm trying to print a document with this code:
The problem is, when the print dialog shows up and I click OK to print, I get the Message 'Word is currently printing. Quitting Word will cancel all pending print jobs. Do you want to quit Word?'Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim wrdApp As New Word.Application wrdApp.Documents.Open("C:\temp\temp.doc") wrdApp.Dialogs.Item(Word.WdWordDialog.wdDialogFilePrint).Show() wrdApp.Visible = False wrdApp.ActiveDocument.Close() wrdApp.Quit() End Sub
If I click Yes the document is not printed but Word disappears. Clicking No, the document prints but the Word application is still open and has to be closed manually.
Is there a way to tell when the Word app is fininished sending the document to the printer so I can call wrdApp.Quit()?




Reply With Quote