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

Posted on 2012-08-21
Last Modified: 2012-08-27
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?
Question by:OSI-IT
    LVL 22

    Expert Comment

    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.

    LVL 22

    Accepted Solution

    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.
    LVL 76

    Expert Comment

    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.

    Author Comment

    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).

    Author Closing Comment

    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

    Featured Post

    A Knowledge Base That Stays Up-to-Date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
    This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
    Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now