返回一個 UserAccessList 集合后,便可用 Count 屬性來確定訪問受保護區域的用戶數量。在下例中,Microsoft Excel 將訪問第一個受保護區域的用戶的數量通知給用戶。本示例假定受保護的區域位于活動工作表上。
代碼如下:
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
更多信息請查看IT技術專欄