?
Solved

WINWORD.EXE not closing after mWordObject.ActiveDocument.PrintOut()

Posted on 2006-11-14
4
Medium Priority
?
937 Views
Last Modified: 2008-01-09
I have a requirement where i need to print set of documents and this is working fine. But all the WINWORD.EXE's for each document are staying in Task Manager and i have to manually end all the processes.

Please let me know how to overcome this. If i do this

                mWordObject.Application.Quit()
                mWordObject = Nothing

It closes the WINWORD.EXE but it closes even before it prints. I want to know if there is a method which can find when the printing is done and then closes the WINDWORD.EXE files.

Any help/suggestions would be really helpful.

Thanks
Sureshj
0
Comment
Question by:smaram1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:smaram1
ID: 17942524
Actually this doesnt work too...

                mWordObject.Application.Quit()
                mWordObject = Nothing
0
 
LVL 16

Expert Comment

by:Hillwaaa
ID: 17944792
Hi smaram1,

Try the following:

mWordObject.ActiveDocument.PrintOut()
Do While objWord.BackgroundPrintingStatus > 0
Loop

mWordObject.Application.Quit()
mWordObject = Nothing

Let me know if that doesn't work.

Cheers!
0
 
LVL 16

Accepted Solution

by:
Hillwaaa earned 1000 total points
ID: 18136192
To verify my solution, here's a sample hello world scenario - where a new document is created, hello world written to the new doc, it is printed, and after the printing is complete, the doc is closed.

        Dim oWord As Microsoft.Office.Interop.Word.Application
        Dim oDoc As Microsoft.Office.Interop.Word.Document
        Dim oPara1 As Microsoft.Office.Interop.Word.Paragraph

        oWord = CreateObject("Word.Application")
        oWord.Visible = True
        oDoc = oWord.Documents.Add

        'Insert a paragraph at the beginning of the document.
        oPara1 = oDoc.Content.Paragraphs.Add
        oPara1.Range.Text = "Hello World!"
        oPara1.Range.Font.Bold = True

        oWord.ActiveDocument.PrintOut()

        'Wait for printing to complete.
        Do While oWord.BackgroundPrintingStatus > 0
        Loop

        oDoc.Close(False) 'Close without saving

        oWord.Application.Quit()
        oWord = Nothing
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question