Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-11-14
4
Medium Priority
?
940 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

618 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