Share via


_Chart.Protect Method

Protects a chart so that it cannot be modified.

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

Syntax

'Declaration
Sub Protect ( _
    Password As Object, _
    DrawingObjects As Object, _
    Contents As Object, _
    Scenarios As Object, _
    UserInterfaceOnly As Object _
)
'Usage
Dim instance As _Chart
Dim Password As Object
Dim DrawingObjects As Object
Dim Contents As Object
Dim Scenarios As Object
Dim UserInterfaceOnly As Object

instance.Protect(Password, DrawingObjects, _
    Contents, Scenarios, UserInterfaceOnly)
void Protect(
    Object Password,
    Object DrawingObjects,
    Object Contents,
    Object Scenarios,
    Object UserInterfaceOnly
)

Parameters

  • Password
    Type: System.Object

    Optional Object. A string that specifies a case-sensitive password for the worksheet or workbook. If this argument is omitted, you can unprotect the worksheet or workbook without using a password. Otherwise, you must specify the password to unprotect the worksheet or workbook. If you forget the password, you cannot unprotect the worksheet or workbook. It's a good idea to keep a list of your passwords and their corresponding document names in a safe place.

  • DrawingObjects
    Type: System.Object

    Optional Object. True to protect shapes. The default value is False.

  • Contents
    Type: System.Object

    Optional Object. True to protect contents. For a chart, this protects the entire chart. For a worksheet, this protects the locked cells. The default value is True.

  • Scenarios
    Type: System.Object

    Optional Object. True to protect scenarios. This argument is valid only for worksheets. The default value is True.

  • UserInterfaceOnly
    Type: System.Object

    Optional Object. True to protect the user interface, but not macros. If this argument is omitted, protection applies both to macros and to the user interface.

Remarks

Use strong passwords that combine upper- and lowercase letters, numbers, and symbols. Weak passwords don't mix these elements. Strong password: Y6dh!et5. Weak password: House27. Use a strong password that you can remember so that you don't have to write it down.

See Also

Reference

_Chart Interface

_Chart Members

Microsoft.Office.Interop.Excel Namespace