problem intercepting application level document close event

C

Chip Orange

I have the following code segment designed to intercept all document
closings in Word 2002 under win2k:

Public WithEvents wdApp As Word.Application

Private Sub Document_New()
'assign Word to the application variable
If wdApp Is Nothing Then
Set wdApp = Application
End If

End Sub

Public Sub wdApp_DocumentBeforeClose(ByVal Doc As Document, Cancel As
Boolean)
If strOpenedRecFile = Doc.Name Then

....

The reference to doc.name sometimes causes an "object has been deleted"
error which is rarely reproducable.

Any ideas?

thanks.

Chip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top