Solved

Word Report - open / close best way?

Posted on 2003-12-01
6
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

695 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