Link to home
Start Free TrialLog in
Avatar of cplau
cplau

asked on

Word Document Printing Issue

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
        My_Word.ObjWordBasic.fileprint(0)
End If
.........
If My_Word.ObjWordBasic IsNot Nothing Then
                My_Word.ObjWordBasic.fileexit(2)
                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.
Avatar of Hawkvalley1
Hawkvalley1
Flag of United States of America image

Use Marshal.FinalReleaseComObject(comobject)
Avatar of Paul Jackson
Why are you using com when vb.net has intrinsic word automation
see here : http://www.codeproject.com/KB/office/WordPrint.aspx
ASKER CERTIFIED SOLUTION
Avatar of Hawkvalley1
Hawkvalley1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cplau
cplau

ASKER

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