Hi,
I have a document which needs to do a couple of actions before it is saved.
I have a Macro for that. It works fine, the only issue is, that it is also triggered in all other open documents and that is not what I want.
It only needs to be triggered in the document itself.
The code I am using:
Microsoft Word Objects:ThisDocument:
Private Sub Document_New()
Register_Event_Handler
End Sub
Private Sub Document_Open()
Register_Event_Handler
End Sub
Module:mdlEventConnect
Dim X As New EventClassModule
Sub Register_Event_Handler()
Set X.App = Word.Application
End Sub
Class Modules:
EventClassModule
Public WithEvents App As Word.Application
___________________________________________________________________________ ________
Private Sub App_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
Dim intResponse As Integer
'Do you want to save question?
intResponse = MsgBox("Do you really want to save the document? ", vbYesNo)
If intResponse = vbNo Then Cancel = True
End Sub
Attached a word document with my code.
Does anybody know how that can be achieved?
Thanks in advance
Olaf