Protect and Upprotect - Word 2007 Doc


New Member
Feb 4, 2013

I've got a template in Word 2007 that I'm creating that several people will be using and, to avoid issues from people accidentally changing or deleting stuff in the document, I'm restricting editting to form fields only and password protecting it. What I want to happen is for the macro to run, unprotect the document, save it as a separate, macro-free file and then protect the document WITHOUT the password in order to prevent people from accidentally making changes, but allowing them to make intentional edits in case they need to reformat, clean up data, etc.

So my template starts out as protected and here's the code that I'm using:

ActiveDocument.Unprotect Password:=Pwd
'rest of code here
Pwd = ""
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=Pwd
ActiveDocument.SaveAs "OtherFile.doc"

The problem I'm running into is that, when I close the document and open the "OtherFile.doc" that was saved, it still has "Password" as the password. I've tried it without defining a password before it's saved at all as well as not using a variable and just an emplty string, so
at the end, but it all results in the same - which I expected but thought it worth a shot.

Any suggestions on how to remedy this?

Best Regards,


Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Since you're using Word 2007, why not take advantage of its editing restrictions. They're far more flexible than what formfields provide and don't require macros or passwords.
Upvote 0

Thanks for the input, but the template is a little more complex in that it's designed to make a certain process we have much more automated. Our current process requires our employees to cut and paste certain cells from an Excel file into the document which is then provided to our clients to provide to their employees as a notice of changes in the services available to them. This process was causing some of the less technologically inclined some issues, so I designed the template to automatically pull from the Excel file and populate the tables and form fields in the docuemnt. Some of the information from the Excel file may need tweaking, so I plan on leaving the form fields so that the information can be changed without changing the whole document. If the user wants to edit the document, they have that option, but I want to make it a little more difficult so that the changes are more deliberate.

I'm not in a very tech savvy industry - I'm actually still in the early stages of learning myself - so I'm trying to make this as idiot proof as I can
Upvote 0
OK, If your macro is in the form's template (ie a .dot file), it will be available to all files based on that template - while they're on your system - but not available elsewhere. Accordingly, the clients would never see the code or the password. Conversely, if you do include the code in the documents, you can password-protect the vba module it's in, so that no-one who doesn't know the module's password can see the code in it.
Upvote 0
I hadn't thought about password protecting the macro, so thanks for that. What I'm concerned about more here is the document itself, though. I have bookmarks in the document that I call on in the macro to skip around and add/remove sections as needed. What I don't want to happen is for someone to accidentally delete a bookmark and then the macro not work properly, for one, and make it so they can only make deliberate changes in the new document that is created. It's not for any true security, simply to dummy proof it, but I can't seem to find any reason why the password reverts to the original password instead of it not having one... Is that something that Word does often?

Thanks, again, for your help.

Also, not a true template and the macro is going to follow the document until the new one is populated and saved. Sorry for the confusion on that.
Upvote 0
Relying on bookmarks in editable portions of a document is fraught with danger. As you've observed, they might get deleted. They might even get cut & pasted to an entirely different location. Since you're using Word 2007, you might do better to use the 'read-only' restrictions and mark out the exception areas that people are allowed to edit. If you then keep the bookmarks in the restricted portions, they'll not be in danger of deletion/moving.

It tested your code and cannot replicate your experience - the original password gets deleted as the code implies it should.
Upvote 0

Forum statistics

Latest member

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back