PROTECT.DOCUMENT macro

Adds protection to or removes protection from the active sheet, macro sheet, chart, dialog sheet, module, or scenario. Use PROTECT.DOCUMENT to prevent yourself or others from changing cell contents, or objects in a workbook. To protect workbooks in Microsoft Excel version 5.0 or later, see WORKBOOK.PROTECT.

Syntax

PROTECT.DOCUMENT(contents, windows, password, objects, scenarios)

PROTECT.DOCUMENT?( contents, windows, password, objects, scenarios)

Contents    is a logical value corresponding to the Contents check box in the Protect Sheet dialog box.

 

Windows    is provided for compatibility with Microsoft Excel version 4.0. To protect the window placement and structure of workbooks in Microsoft Excel version 5.0 or later, see WORKBOOK.PROTECT.

 

Password    is the password you specify in the form of text to protect or unprotect the file. Password is case-sensitive.

 

Objects    is a logical value. This argument applies only to charts, worksheets and macro sheets. Objects corresponds to the Objects check box in the Protect Sheet dialog box.

Scenarios    is a logical value that corresponds to the Scenarios check box on the Protect Sheet dialog box. If TRUE, Microsoft Excel protects all the scenarios. If FALSE, the scenarios are not protected.

Remarks

 

Warning   If you forget the password of a workbook that was previously protected with a password, you cannot unprotect the workbook.

Related Functions

CELL.PROTECTION   Controls protection for the selected cells

ENTER.DATA   Turns Data Entry mode on and off

OBJECT.PROTECTION   Controls how an object is protected

SAVE.AS   Saves a workbook and allows you to specify the name, file type, password, backup file, and location of the workbook

WORKBOOK.PROTECT   Protects a workbook

Return to index