Prevent Changes to Password Used for Enforced Format Protection within MS Word 2007

Here's the scenario;

MS Word 2007 document that is password protected (in order to open the document), but then also password protected (to protect formatting of the document itself).

When authorized users need to update the document, of course they click on "stop protection" (enter the valid password), and make the needed edits.  Once completed, they click on "Yes, Start Enforcing Protection"...which then prompts for a NEW password.  

Most of the time, there's no issues, but every so often someone mistypes the "new" password (we use standard passwords that are changed every 90 days), which then of course creates problems later.

Is there a way to prevent the user from changing the password that is used to protect document?  Through code or specific setup of the document?
Who is Participating?
FlysterConnect With a Mentor Commented:
Actually, if you want to go this route, I suggest one more change as follows:

Sub AutoClose()

    ActiveDocument.Protect Password:="Password", NoReset:=False, Type:= _
        wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False

End Sub

This will automatically save the document and activates the password. In the other code there is a prompt to save when you try to close.
If you're looking for a macro, you can use:

Sub SetPassword()

    ActiveDocument.Protect Password:="YourPassword", NoReset:=False, Type:= _
        wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False
End Sub

Just change "YourPassword" to the actual password. The down side to using code is that anyone can open VB and see what the code is. You can also make this an automatic process by changing Sub SetPassword() to Set AutoClose(). This will run the code every time the form is closed.

The internal Editing Restrictions protection is a convenience against inadvertent editing changes, and not really a security measure, so it is generally unnecessary to use a password at all.

Anyway the protection is easily removed, so you can fix forgotten passwords.

Create a new blank document and click the Object dropdown in the Text group of the Insert tab. Choose 'Text from File...' and browse for the protected document. Note that you will still have to know the password to Open the file.
OSI-ITAuthor Commented:
Thank you both for your comments.

@GrahamSkan - The reason for both a document password and editing password is that the document goes through various editing and final approval processes.  The doc password of course is meant to prevent opening by unauthorized people, while the editing password is meant to prevent "accidental" changing of content within the document by the final recipients.

@Flyster - I tried both code snipets, but experience a run time error '4605' when closing the document IF no changes to the document has been made (as if I simply opened the document to read it, and then I close it).
OSI-ITAuthor Commented:
This code worked perfectly, except in the instance where the user attempts to close the document without making any changes AND does not remove edit protection...which then results in an error.

So a quick 'if' statement corrected's what the final code looked like...

    If ActiveDocument.ProtectionType = wdNoProtection Then
        ActiveDocument.Protect Password:="password", NoReset:=False, Type:=wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False
    End If

thanks for the assist
All Courses

From novice to tech pro — start learning today.