Word Document Printing Issue

Posted on 2011-05-04
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
    LVL 9

    Expert Comment

    Use Marshal.FinalReleaseComObject(comobject)
    LVL 29

    Expert Comment

    by:Paul Jackson
    Why are you using com when has intrinsic word automation
    see here :
    LVL 9

    Accepted Solution

    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

    Hi Hawkvalley1,
    Thanks. I will test your suggestion later.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    I'm currently working for a company where I have to upgrade over 50 VB6 programs to VB.NET 2008.  So far I'm about half way through, and I've learned quite a few tricks that drastically improve the performance of VB.NET apps. Because there are a…
    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now