Microsoft Office Tutorials and References
In Depth Information
18.3.3 The UserAccess Objects
The methods of the AllowEditRange object are:
ChangePassword
Changes the password associated with the AllowEditRange object.
Delete
Deletes the AllowEditRange object.
Unprotect
Unprotects the workbook.
18.3.3 The UserAccess 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.
18.4 Example: Printing Sheets
We can now implement the PrintSheets feature of our SRXUtils application. Recall that at the
present time, this Print utility, located in the Print.utl add-in, simply displays a message box. To
implement this feature, we want the utility to first display a dialog box, as shown in Figure 18-7 .
The list box contains a list of all sheets in the active workbook. The user can select one or more
sheets and hit the Print button to print these sheets.
Figure 18-7. Print sheets dialog
 
 
Search JabSto ::




Custom Search