Solved

Word Report - open / close best way?

Posted on 2003-12-01
6
239 Views
Last Modified: 2012-08-14
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.

0
Comment
Question by:Valliappan AN
  • 3
  • 2
6 Comments
 
LVL 26

Accepted Solution

by:
EDDYKT earned 125 total points
ID: 9852030
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:="", _
        Format:=wdOpenFormatAuto
End Sub

Private Sub wdApp_Quit()
Debug.Print "close"
End Sub
0
 
LVL 9

Author Comment

by:Valliappan AN
ID: 9863305
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.

Thanks
0
 
LVL 9

Author Comment

by:Valliappan AN
ID: 9863322
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.
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 26

Expert Comment

by:EDDYKT
ID: 9866086
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
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 10167431
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.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

leonstryker
EE Cleanup Volunteer
0
 
LVL 9

Author Comment

by:Valliappan AN
ID: 10228996
I am afraid, it didnot enter the Close event when manually closed the Word window. So, grade B.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 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

12 Experts available now in Live!

Get 1:1 Help Now