Name

worksheet.Protect([Password], [DrawingObjects], [Contents], [Scenarios], [UserInterfaceOnly], [AllowFormattingCells], [AllowFormattingColumns], [AllowFormattingRows], [AllowInsertingColumns], [AllowInsertingRows], [AllowInsertingHyperlinks], [AllowDeletingColumns], [AllowDeletingRows], [AllowSorting], [AllowFiltering], [AllowUsingPivotTables])

Synopsis

Protects a worksheet and sets options determining which items on the worksheet are protected. The arguments to this method correspond to the settings on the Protect Sheet dialog box shown in Figure 26-7.

Argument

Settings

Password

The password required to unprotect the worksheet.

DrawingObjects

True protects graphic objects such as command buttons and shapes on the worksheets; False does not protect. Default is True.

Contents

True protects the locked cells on the worksheet; False does not protect. Default is True.

Scenarios

True protects scenarios on the worksheets; False does not protect. Default is True.

UserInterfaceOnly

True protects the worksheet from changes made through the Excel interface, but allows macros to make changes to protected items; False applies the protection to both types of changes. Default is False.

AllowFormattingCells, AllowFormattingColumns, AllowFormattingRows, AllowInsertingColumns, AllowInsertingRows, AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows, AllowSorting, AllowFiltering, AllowUsingPivotTables

If the contents are protected, then setting any of these ...

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.