Protect A Chart

You can protect a chart so that a user cannot modify it using the Protect method. When you protect a chart you typically password protect it to eliminate the ability to modify it.

The Protect method uses different optional parameters that enable you to customize the type of protection that you assign to the chart. All but one of these parameters accept only True or False to indicate whether or not that type of protection is active for the workbook. The following code illustrates use of the Protect method with a chart: Charts(1). Protect(Password, DrawingObjects, Contents, Scenarios, UserInterfaceOnly) .

Although optional, to effectively protect the chart, you need to specify the password. You can use any string, but remember that it is case-sensitive. This means that Excel treats uppercase and lowercase letters as different characters. In other words, Excel interprets Password and PASSWORD differently, even though they are the same word.

All other parameters of the Protect method accept only True and False values. You use the DrawingObjects parameter to protect any shapes you add to your chart with the drawing options in Excel. The default value of this parameter is False. By default, Excel protects the entire chart and scenarios if you protect a chart. To remove the protection, specify a value of False for the Contents parameter. To unprotect scenarios, specify a value of False for the Scenarios parameter. If you do not use the UserInterfaceOnly parameter, Excel applies the protection to macros and the user interface options for the chart. If you only want to protect the user interface, specify a value of True for the UserInterfaceOnly parameter.

You can unprotect a chart using the Unprotect method with the corresponding password for the chart.

PROTECT A CHART

PROTECT A CHART

Create a new subroutine.

-0 Type Charts(1).Protect, replacing Charts(1) with a reference to the chart to protect.

Create a new subroutine.

-0 Type Charts(1).Protect, replacing Charts(1) with a reference to the chart to protect.

0 0

Post a comment