Workbook.Protect Method

Protects a workbook so that it cannot be modified.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Syntax

'Declaration
Sub Protect ( _
    Password As Object, _
    Structure As Object, _
    Windows As Object _
)
void Protect(
    Object Password,
    Object Structure,
    Object Windows
)

Parameters

  • Password
    Type: System.Object
    A case-sensitive password for the workbook. If this argument is omitted, you can unprotect the workbook without using a password. Otherwise, you must specify the password to unprotect the workbook.
  • Structure
    Type: System.Object
    true to protect the structure of the workbook (the relative position of the sheets). The default value is false.
  • Windows
    Type: System.Object
    true to protect the workbook windows. If this argument is omitted, the windows are not protected.

Remarks

Use strong passwords that combine uppercase and lowercase letters, numbers, and symbols. Weak passwords do not mix these elements. For example, "Y6dh!et5" is a strong password, but "House27" is a weak password. Use a strong password that you can remember so that you do not have to write it down.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

.NET Framework Security

See Also

Reference

Workbook Interface

Microsoft.Office.Tools.Excel Namespace