Tools Protect Unprotect Document macro in Version 2003

J

Jamie

I recently upgraded from Word 2002 to 2003 and the following macro does not
function as it did in the 2002 version.

My department creates templates for other units. We do not want the users
to be able to unlock the templates so we attached the following macros to the
forms.

Sub ProtectForm()
'
' ProtectForm Macro
' Toggles protection for the active document
'
Dim Msg, Style, Title, Response

Msg = "This form is protected, please contact SAS for revisions." 'Define
message.
Style = vbCritical 'Define buttons.
Title = "Warning" 'Define Message Box title.

Response = MsgBox(Msg, Style, Title)
End Sub

Sub ToolsProtectUnprotectDocument()
'
' ToolsProtectUnprotectDocument Macro
' Macro created 3/29/2006 by Jamie Shaw
'
Dim Msg, Style, Title, Response

Msg = "This form is protected, please contact SAS for revisions." 'Define
message.
Style = vbCritical 'Define buttons.
Title = "Warning" 'Define Message Box title.

Response = MsgBox(Msg, Style, Title)
End Sub

The ProtectForm macro functions as before, however the
ToolsProtectUnprotectDocument macro does not. Now when the user goes to
Tools, Unprotect Document a Protect Document window opens with the following
choices: 1. Formatting restrictions, 2. Editing restrictions, and 3. Start
enforcement.

I would like the ToolsProtectUnprotectDocument macro to function as it did
before; when the user goes to Tools, Unprotect Document the message box
appears stating This form is protected, please contact SAS for revisions.
Can this be accomplished and if so, how?

Thanks for your help.
 
D

Doug Robbins - Word MVP

Sounds like the document is unprotected. Use the following:

Dim Msg, Style, Title, Response

If ActiveDocument.ProtectionType = wdNoProtection Then
Exit Sub
Else
Msg = "This form is protected, please contact SAS for revisions."
'Define message.
Style = vbCritical 'Define buttons.
Title = "Warning" 'Define Message Box title.

Response = MsgBox(Msg, Style, Title)
End If


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
E

Ed

Hi Jamie,

When I check the built-in commands in Word 2003 under Tools/Macro/Macros
(choosing "Word commands" in the "Macros in" box) there is a ToolsProtect
command and a ToolsProtectUnprotectDocument command. However, when I select
the ToolsProtectUnprotectDocument command the "Run" option is greyed out.
Don't know exactly what this signifies but it looks like that command is no
longer available.

The ToolsProtect command seems to be the one that Word 2003 uses so try
renaming your macro to that.

(To check which command is being run by the menu option you can hold down
Ctrl and Alt and press the plus key on the numeric keypad and when the cursor
displays a bit like a four-leaf clover, click Tools/Protect (or Unprotect).
This displays a "Customize keyboard" dialog which shows what command is
associated with the menu item you selected.)

Cheers.

Ed
 
E

Ed

Oops! Just noticed that the Ctrl-Alt-+ thing doesn't seem to work if the doc
is protected, but does if it isn't.

Regards.

Ed
 
J

Jamie

Thanks Doug I will give it a try.
--
Jamie


Doug Robbins - Word MVP said:
Sounds like the document is unprotected. Use the following:

Dim Msg, Style, Title, Response

If ActiveDocument.ProtectionType = wdNoProtection Then
Exit Sub
Else
Msg = "This form is protected, please contact SAS for revisions."
'Define message.
Style = vbCritical 'Define buttons.
Title = "Warning" 'Define Message Box title.

Response = MsgBox(Msg, Style, Title)
End If


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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