Build user list : User Access « Access « VBA / Excel / Access / Word






Build user list

 

Sub BuildUserList()
    Dim ws As Worksheet, ual As UserAccessList, aer As AllowEditRange, _
      usr As UserAccess
    Set ws = ThisWorkbook.Sheets("Protection")
    ws.Unprotect "Excel2003"
    Set aer = ws.Protection.AllowEditRanges("Edit Range")
    Set ual = aer.Users
    Set usr = ual.Add("Administrators", True)
    Set usr = ual.Add("Users", True)
    Set usr = ual.Add("Guests", False)
    For i = 1 To ual.Count
        Set usr = ual(i)
        Debug.Print usr.Name
    Next
    ws.Protect "Excel2003"
End Sub

 








Related examples in the same category

1.Add Edit Range
2.Remove Edit Ranges
3.Show Edit Ranges
4.Unlock Edit Range
5.Delete user list