The User Access Objects

UserAccess objects allow certain users to access a protected range without requiring the password. For instance, if your username is steve, then the following code will allow you to access protected ranges:

Sub AddUser()

Dim ws As Worksheet Dim ua As UserAccess

Set ws = Application.ActiveSheet

' NOTE: Sheet must be unprotected for this code to work! ws.Unprotect

Set ua = ws.Protection.AllowEditRanges(1).Users.Add("steve", True) End Sub

Note that the worksheet must be unprotected for this code to run without error.

The UserAccess object has but three members: the AllowEdit Boolean property, the read-only Name property, and the Delete method.

The UserAccessList collection holds the current UserAccess objects.

0 0

Post a comment