rcoppi said:
I have an application that invokes MS WORD to generate documents
necessary
for tasks completed within the application. I currently have macros
that link the two applications together but I need to create a macro
or something that would prevent a single document or a group of
mail-merge documents generated from being modified X number of days
after the document(s) were originally saved. Any ideas? We just
switched from DDE to OLE if that helps.
There isn't a lot of detail here. Who or what would be attempting to change
the documents, either before or after the cutoff date? What version of Word
is being used? Where are the current batch of macros -- somewhere in Word,
or in this other application (and what is that?)?
Word in general has a lot of trouble with this sort of task. Yes, you can
write an AutoOpen macro that compares the current date to the document's
creation date and, when necessary, applies some form of protection. If
you're working with Word 2003 or later, there is a "No changes (Read only)"
protection that can be applied with a password; in Word 2002 and earlier,
the best you can do is forms protection, whose password is easily bypassed.
There are two problems with this approach: (a) Macros stored in documents
(as opposed to those in templates in trusted locations) are considered
likely to be viruses, so the user may be required to enable them, or they
may just be disabled silently, depending on security settings. (b) Even if
macros would normally be enabled, any AutoOpen macro can be prevented from
running by holding down the Shift key. So if you're concerned with a
deliberate "attack" on a document that shouldn't be modified, the macro
won't be an adequate defense.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.