Link to home
Start Free TrialLog in
Avatar of OSI-IT
OSI-IT

asked on

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?
Avatar of Flyster
Flyster
Flag of United States of America image

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.

Flyster
ASKER CERTIFIED SOLUTION
Avatar of Flyster
Flyster
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of OSI-IT
OSI-IT

ASKER

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).
Avatar of OSI-IT

ASKER

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 that...here's what the final code looked like...

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

thanks for the assist