Solved

Word Report - open / close best way?

Posted on 2003-12-01
6
234 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 26

Expert Comment

by:EDDYKT
Comment Utility
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
Comment Utility
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
Comment Utility
I am afraid, it didnot enter the Close event when manually closed the Word window. So, grade B.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

771 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

11 Experts available now in Live!

Get 1:1 Help Now