UserAccessList 集合的功能(VBA)

字號:


    返回一個 UserAccessList 集合后,便可用 Count 屬性來確定訪問受保護區(qū)域的用戶數(shù)量。在下例中,Microsoft Excel 將訪問第一個受保護區(qū)域的用戶的數(shù)量通知給用戶。本示例假定受保護的區(qū)域位于活動工作表上。
    代碼如下:
    Sub UseDeleteAll()
    Dim wksSheet As Worksheet
    Set wksSheet = Application.ActiveSheet
    ' Notify the user the number of users that can access the protected range.
    MsgBox wksSheet.Protection.AllowEditRanges(1).Users.Count
    End Sub