Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You can protect a Microsoft Office Excel workbook so that users cannot add or delete worksheets, and also unprotect the workbook programmatically. You can optionally specify a password, indicate whether you want the structure protected (so users cannot move sheets around), and indicate whether you want the workbook's windows protected.
Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Excel. For more information, see Features available by Office application and project type.
Protecting a workbook does not stop users from editing cells. To protect the data, you must protect the worksheets. For more information, see How to: Programmatically protect worksheets.
The following code examples use a variable to contain a password that is obtained from the user.
Call the Protect method of the workbook and include a password. To use the following code example, run it in the ThisWorkbook
class, not in a sheet class.
Call the Unprotect method, passing a password if it is required. To use the following code example, run it in the ThisWorkbook
class, not in a sheet class.
Call the Protect method of the workbook and include a password. This code example uses the active workbook. To use this example, run the code from the ThisAddIn
class in your project.
Call the Unprotect method of the active workbook, passing a password if it is required. To use this example, run the code from the ThisAddIn
class in your project.
Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!