Hi
I have not developed in VBA for many years. and i find myself struggling somewhat!
at a high level I'm just wanting to explore the event model that will work across multiple versions of Word. i.e. Word for Mac 2011 and Word 2003 and later.
at a more detailed level, I am building a tool for a legal client to distribute to their internal users that needs to expire every (say) quarter to ensure that it is refreshed formally. the expiry should stop saving documents, printing them and creating new versions based on a template. but not opening them. The expiry should have an override to allow one of the legal team to extend the expiry of a particular document. This is a crude mechanism and I will refine it when I get the basics working.
the expiry date is stored in a customDocumentProperty.
at the moment I can get the menu macros to work but I'm trying to intercept the event model instead as that seems to offer more control.
I have read a bunch of links at mvps and elsewhere.
I currently have the following
In ThisDocument
in a class module called thisApplication
I'm not getting any error messages; just no message boxes.
any pointers greatly appreciated.
An anodyne dotm file is attached if that helps (although I appreciate that noone may want to run a 'foreign' macro on their machine.
I have not developed in VBA for many years. and i find myself struggling somewhat!
at a high level I'm just wanting to explore the event model that will work across multiple versions of Word. i.e. Word for Mac 2011 and Word 2003 and later.
at a more detailed level, I am building a tool for a legal client to distribute to their internal users that needs to expire every (say) quarter to ensure that it is refreshed formally. the expiry should stop saving documents, printing them and creating new versions based on a template. but not opening them. The expiry should have an override to allow one of the legal team to extend the expiry of a particular document. This is a crude mechanism and I will refine it when I get the basics working.
the expiry date is stored in a customDocumentProperty.
at the moment I can get the menu macros to work but I'm trying to intercept the event model instead as that seems to offer more control.
I have read a bunch of links at mvps and elsewhere.
I currently have the following
In ThisDocument
Code:
Option Explicit
Dim oAppClass As New thisApplication
Sub Register_Event_Handler()
Set oAppClass.oApp = Word.Application
End Sub
in a class module called thisApplication
Code:
Option Explicit
Public WithEvents oApp As Word.Application
Private Sub oApp_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
MsgBox ("before print")
End Sub
Private Sub oApp_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
MsgBox ("before save")
End Sub
Private Sub oApp_NewDocument(ByVal Doc As Document)
MsgBox ("new document")
End Sub
Private Sub oApp_DocumentChange()
MsgBox ("document change")
End Sub
I'm not getting any error messages; just no message boxes.
any pointers greatly appreciated.
An anodyne dotm file is attached if that helps (although I appreciate that noone may want to run a 'foreign' macro on their machine.