ChartSheetBase.Unprotect Method (Object)


Removes protection from a Microsoft.Office.Tools.Excel.ChartSheetBase. This method has no effect if the sheet or workbook is not protected.

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

public void Unprotect(
	object password


Type: System.Object

The case-sensitive password to use to unprotect the sheet or workbook. If the sheet or workbook is not protected with a password, this argument is ignored. If you omit this argument for a sheet that is protected with a password, you will be prompted for the password. If you omit this argument for a workbook that is protected with a password, the method fails.

If you forget the password, you cannot unprotect the Microsoft.Office.Tools.Excel.ChartSheetBase. It is a good idea to keep a list of your passwords and their corresponding document names in a safe place.

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

The following code example uses the Protect method to protect all contents of the current Microsoft.Office.Tools.Excel.ChartSheetBase. The example then uses the ProtectContents property to verify that the chart sheet is protected, and then prompts the user to remove protection from the chart sheet by using the Unprotect method.

private void ChartSheetProtection()
    Globals.Sheet1.Range["A1", "A5"].Value2 = 22;
    Globals.Sheet1.Range["B1", "B5"].Value2 = 55;

    this.SetSourceData(Globals.Sheet1.Range["A1", "B5"],
    this.ChartType = Excel.XlChartType.xl3DColumn;

    this.Protect(true, true, true, false);

    if (this.ProtectContents)
        if (DialogResult.Yes ==
            MessageBox.Show("The chart sheet is protected. " +
            "Unprotect the chart sheet?", "Example", 
Return to top