UserAccess 对象

         
UserAccessList
UserAccess

代表对受保护区域的用户访问。

UserAccess 对象用法

可用 Add 方法或 UserAccessList 集合的 Item 属性返回一个 UserAcess 对象。

返回一个 UserAccess 对象后,便可判断是否可用 AllowEdit 属性来访问工作表中的特定区域。下例向受保护的工作表添加可编辑的区域,并将该区域的标题通知给用户。

Sub UseAllowEditRanges()

    Dim wksSheet As Worksheet

    Set wksSheet = Application.ActiveSheet

    ' Add a range that can be edited on the protected worksheet.
    wksSheet.Protection.AllowEditRanges.Add "Test", Range("A1")

    ' Notify the user the title of the range that can be edited.
    MsgBox wksSheet.Protection.AllowEditRanges(1).Title

End Sub