Document_Close event does not occur.

T

TOM

I have programmed VB for a long time but not Word VBA.

I have created a Document_Close event in the ThisDocument
class module within the Project folder of my document.

I added a MsgBox statement to test it.

The event does NOT fire when I close my document.
Any ideas.
 
P

Peter Hewett

Hi TOM

Have you hooked up the event handler declared in the WithEvents statement?

If so, post your code (well the relevant parts!) and we'll try to sus out what's
going on.

HTH + Cheers - Peter
 
Å

Åsa Holmgren

Have you checked what level of macro security you are using? With High
security the code will be ignored. Medium security will let you choose to
activate the code or not when you open the document.

/Asa H
 
T

TOM

Um... the "event handler declared in the WithEvents
statement"

So the code does not run until I tell Word that I really
really mean to want to right now and not some other time
but really now like hurry please...

So for being facetious.

Why the heck do I need to tell Word to run by means other
than the simple code:

Private Sub Document_Close()
MsgBox "Closing"
End Sub
 
T

TOM

It's the macro security thing, thanks.

I want to bypass the security dialogue when opening the
document as I am trying to minimize user interaction when
merging documents. Is there a way?
 
P

Peter Hewett

Hi TOM

Sorry it was late when I wrote it! I though you wanted to respond to Word
application events.

Cheers - Peter


Um... the "event handler declared in the WithEvents
statement"

So the code does not run until I tell Word that I really
really mean to want to right now and not some other time
but really now like hurry please...

So for being facetious.

Why the heck do I need to tell Word to run by means other
than the simple code:

Private Sub Document_Close()
MsgBox "Closing"
End Sub

HTH + Cheers - Peter
 

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