Protection property (Document object)

Microsoft Visio Developer Reference

Protection property (Document object)

   Example   

Determines how a document is protected from user customization.

Version added

2002

Syntax

retVal = object.Protection ([bstrPassword])
object.Protection ([bstrPassword]) = newValue

retVal

VisProtection. The current protection settings.

object

Required. An expression that returns a Document object.

bstrPassword

Optional Variant. The existing password.

newValue

Required VisProtection. The new protection settings.

Remarks

If the document is password protected, you must provide the existing password to set the Protection property. If you provide an incorrect password, the Protection property will raise an exception.

The Protection property ignores bstrPassword when you are getting the value of the property.

This property is the equivalent of checking the Styles, Shape, Preview, Backgrounds, and Master shapes boxes on the Protect Document dialog box (in the Drawing Explorer, right-click the drawing name, and then click Protect Document). If there is an existing password, you must first remove it by entering it in the Unprotect Document dialog box (in the Drawing Explorer, right-click the drawing name, and click Unprotect Document).

The value of retVal and newVal can be a combination of the following VisProtection constants.

Constant

Value

visProtectNone

&H0

visProtectStyles

&H1

visProtectShapes

&H2

visProtectMasters

&H4

visProtectBackgrounds

&H8

visProtectPreviews

&H10