Word Document Printing Issue

Posted on 2011-05-04
Medium Priority
Last Modified: 2012-06-27
I am trying to print a Word 2003 document in my program by using an Interop object downaloded from Microsoft. (Interop.Word.dll). Below lists part of my code.

Public ObjWordBasic As Object
Public WordApp As Word.Application

My_Word.WordApp = CreateObject("word.application")
My_Word.WordApp.Documents.Open(WordFilePath & WordFileName)

My_Word.ObjWordBasic = CreateObject("Word.Basic")
If My_Word.ObjWordBasic IsNot Nothing Then
End If
If My_Word.ObjWordBasic IsNot Nothing Then
                My_Word = Nothing
End If

Somehow, oscasionally, I found that there is a WinWord.exe process left when checking the WIndows Task Manager after the printing. This causes the printing of another document failed.
I need to manually kill the WinWord.exe process left to resume the printing.

Please advise how I can rectify this problem. Thanks.
Question by:cplau
  • 2

Expert Comment

ID: 35695608
Use Marshal.FinalReleaseComObject(comobject)
LVL 29

Expert Comment

by:Paul Jackson
ID: 35695615
Why are you using com when vb.net has intrinsic word automation
see here : http://www.codeproject.com/KB/office/WordPrint.aspx

Accepted Solution

Hawkvalley1 earned 1000 total points
ID: 35695693
You still need the method I provided to release that object, I have tested that quite thoroughly. I also think you should just call My_word.WordApp = NewWord.Application, rather that CreateObject. You will have less trouble releasing it.

Author Comment

ID: 35695710
Hi Hawkvalley1,
Thanks. I will test your suggestion later.


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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month16 days, 3 hours left to enroll

850 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