Bagikan melalui


Excel Document Protection Techniques Sample

Note

This sample runs only in Microsoft Office Excel 2007.

This sample demonstrates various techniques you can use to protect structural components of a worksheet. These techniques can help to prevent users from accidentally deleting controls or otherwise changing important parts of your solution document.

Security noteSecurity Note:

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 this sample

  1. Press F5.

  2. Follow the instructions on Sheet1 and Sheet2.

Demonstrates

  • How to re-create a control after a user deletes it.

  • How to write data to a data-bound ListObject control on a protected worksheet.

  • How to write data to a NamedRange control on a protected worksheet.

  • How to protect a value in a NamedRange control from unauthorized modifications.

  • How to protect a Windows Forms control so that it cannot be modified or deleted by the user, but can be accessed by your code.

See Also

Tasks

How to: Permit Code to Run Behind Documents with Restricted Permissions

Concepts

Document Protection in Document-Level Solutions

Password Protection on Office Documents

Information Rights Management and Managed Code Extensions Overview

Other Resources

Document-Level Samples