Document Protector Sample
This sample runs only in Microsoft Office Word 2007.
This sample demonstrates how to protect a Word document and the document structure. The sample tool protects the entire document and then enables you to unprotect any or all bookmarks, form fields, and XML nodes that are in the document. You also have the option to password-protect the document.
This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.
To run the sample
On the File menu, click Open, and then browse to the document you want to protect.
Select the items that you do not want to be protected.
Optionally, you can assign a password to the document by clicking Password on the Protection menu.
On the Protection menu, click Protect to apply the protection to the document.
On the File menu, click Save to save your work.
On the File menu, click Exit to exit the Document Protector sample tool.
The Document Protector sample tool protects the document and then enables you to select the types of items (XML nodes, form fields, or bookmarks) you want to make available for editing.