Prohibiting a Document From Being Unprotected

J

Jamie

Hi I'm working in Word 2002.

My team and I create templates for our Agency to use. These templates are
protected so the user can complete the fields. What is happening is the
users are unprotecting the documents and altering the form contents.

How can or can I, create a macro that will close the form out if the user
either clicks on the protect button on the Forms toolbar or if they click on
Tools, Unprotect Document?

Thanks for your assistance.
 
J

Jay Freedman

The simplest thing is to apply a password when you protect the template. That
way, no one can unprotect a document based on the template unless they have
the password. (I hesitate to tell you how easy it is to bypass this password
protection, but most users don't know the trick so you're probably safe.)

By writing macros with the names of the corresponding internal commands, you
can intercept the menu and button and take whatever action you want. (See
http://www.word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm.)

The button on the Forms toolbar is intercepted by any macro named ProtectForm.

The menu item on the Tools menu in Word 2002 and 2003 is intercepted by a
macro named ToolsProtect. The same item in Word 2000 (and probably in Word
97, but I don't have that handy) is intercepted by a macro named
ToolsProtectUnprotectDocument.

I don't think suddenly closing the form is a good action to take in these
macros -- you'll get a lot of support calls complaining that "you broke
Word". If you leave the macro's body empty, clicking the button or menu item
will simply do nothing. Alternatively, you could display a messagebox that
says something like "Altering this form is prohibited" or "Touch that button
again and you're fired!"

If your users have Word 2002/2003, there is no macro method to intercept the
user opening any task pane, switching to the Protect Document pane, and
clicking the Stop Enforcing Protection button. Requiring a password is the
only way to stop that approach.
 
J

Jamie

Hi Jay, I went to the InterceptSavePrint link you provided and I'm not sure
how to alter that coding to fit my situation. I understand I'll need two
macros; one for the button - ProtectForm and the other for the Tools Menu -
ToolsProtect.

I'm just not sure about the coding. Any help you can give me to get started
would be great.

Thanks,
 
J

Jay Freedman

As I wrote before, if you simply want to disable the unprotect
commands, you create the two macros but leave them empty:

Sub ProtectForm
End Sub

Sub ToolsProtect
End Sub

If you want to give the user some clue about why the commands don't
work, insert a MsgBox statement inside each macro.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
J

Jamie

Oh, sorry you had to spell it out for me Jay. I didn't catch the leave them
empty part. I'll give it a try. Thanks again.
 

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