Template said:
Having created a template stored on a shared drive, I do not want
users to be able to modify it.
How can I protect it without the user bringing up a dialogue box when
opening the template as a document?
Put the following macro into the template (or add the code to the AutoOpen
macro if one already exists in the template):
Sub AutoOpen()
Dim msg As String
Dim rsp As Integer
msg = "STOP! You have opened the template" & vbCr _
& ActiveDocument.Name & vbCr & _
"If you mean to change the template, click Yes." _
& vbCr & vbCr & _
"Otherwise, click No and use File > New instead."
If ActiveDocument.Type = wdTypeTemplate Then
rsp = MsgBox(prompt:=msg, _
buttons:=vbYesNo + vbDefaultButton2 + vbCritical, _
Title:="WARNING")
If rsp = vbNo Then
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
End If
End If
End Sub
If the user opens the template itself, either from the File > Open dialog in
Word or by right-clicking the template in Explorer and choosing Open, then
the message box will pop up. If they use File > New to create a document
based on the template (which is what they should be doing), then there won't
be any message.
This still doesn't prevent changes in the template if the user modifies a
style in the document and checks the box for "Add to template", or if they
save AutoText entries or macros to the template. To prevent that, you can
set the Read-Only file property in Explorer, so the user would be prompted
to save the changed template under a different name. If the shared drive is
formatted with NTFS, you can also set the permissions on the template's
folder so that only an administrator has Modify permission; everybody else
should have only Read and List permissions.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.