Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

catching Word.Application Quit event

Status
Not open for further replies.

jel

Programmer
Feb 17, 2002
349
NL
I included the Word.Application object in a VB-class module:
Code:
Private WithEvents objw As Word.Application
This way, my program can start Word, merge data from my application with a Word document, etc. Very nice.
However, I need to do some cleaning up after the user quits Word. Therefore, I want to catch the Quit event with:
Code:
Private Sub objw_Quit()
Unfortunately, it seems that this event is not triggered when the user shuts Word down.
Anybody knows why, and what to do about it?
 
I've not tested this so apologies in advance if it's no use but there is this I've found in the back of a help file which you might be missing. Slightly paraphrasing, it goes...

Before the procedure will run, you must connect the declared object in the class module (objw in your example) with the Application object - i.e. properly initialize the objw variable. You can do this with the following code from any module:

Dim X As New EventClassModule
Sub Register_Event_Handler()
Set X.objw = Word.Application
End Sub

... Like I said, sorry if you've already done this. In any case, let us know how you get on! Ta
 
Still don't get it.
Originally I made a private (withevents) Word.Application object within my own class module, inititialized it within that same class module, and tryed to catch events within that same class module. I didn't catch none.
Looking at your code and MSDNlibrary, I tried to make a new class to handle the events, using a public (withevents) Word.Application, and tried to catch events within that event-handler-class. Still caught nothing.
I feel like I must be missing something very obvious...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top