?
Solved

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

Posted on 2006-11-14
4
Medium Priority
?
942 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
  • 2
3 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

862 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