Word Report - open / close best way?

Could someone tell me, what is the best way to open reports created with Word and show to users? And to close it ?

I see the following problems:

i) certain Word instances remain not closed, in the tasks list, after the application quits.
ii) How to check if user closed Word instance, after viewing the report generated, and then to return with VB app?

 I want to know the best way to open/close/view the generatd Word reports.

Thanks in advance.

Valliappan ANSenior Tech ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this

Add ms word reference

Option Explicit
Private WithEvents wdApp As Word.Application
Private Sub Form_Load()
Set wdApp = CreateObject("word.Application")
wdApp.Visible = True
wdApp.Documents.Open FileName:="c:\temp\tt.doc", ConfirmConversions:=False, ReadOnly:= _
        False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
        "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
End Sub

Private Sub wdApp_Quit()
Debug.Print "close"
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Valliappan ANSenior Tech ConsultantAuthor Commented:
Actually the word doc generated using a class module and then shown. Sometimes ger error, when class module try to access word.application, but user closed already, when class still processing, or class did not close it proper.
Task manager shows some Winword when shutdown computer etc.

Valliappan ANSenior Tech ConsultantAuthor Commented:
Also, the user does not essentially have to close the report, since they can leave it open, so how to check that, otherwise, end up with lot of Word opened already.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

You should just do

wdApp.quit wdDoNotSaveChanges  ' in case something change
set wdApp = nothing

If user close the wd, you should be able to get the event from _close
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered EDDYKT
Please leave any comments here within the next seven days.


EE Cleanup Volunteer
Valliappan ANSenior Tech ConsultantAuthor Commented:
I am afraid, it didnot enter the Close event when manually closed the Word window. So, grade B.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.