[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

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.

0
Valliappan AN
Asked:
Valliappan AN
  • 3
  • 2
1 Solution
 
EDDYKTCommented:
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
 
Valliappan ANAuthor 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.

Thanks
0
 
Valliappan ANAuthor 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.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
EDDYKTCommented:
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
 
leonstrykerCommented:
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
 
Valliappan ANAuthor Commented:
I am afraid, it didnot enter the Close event when manually closed the Word window. So, grade B.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now