Show AllShow All

Permission Property

Returns or sets a Long value representing the permissions on the active document assigned to the user associated with the specified UserPermission object. Read/write Long. The Permission property can be one or a combination of MsoPermission constants.

expression.Permission

expression    Required. An expression that returns a UserPermission object.

Remarks

The UserPermission object associates a set of permissions on the active document with a single user and an optional expiration date. The Permission property returns the set of user permissions determined by the specified UserPermission object. While some permissions granted through the user interface (such as msoPermissionPrint) apply to all users, you can use the UserPermission object to assign them on a per-user basis with per-user expiration dates.

Example

The following example uses the bitwise And operator with the Permission property and an msoPermission constant to determine whether the second user has permission to save the active document.

    Dim irmPermission As Office.Permission
    Dim irmUserPerm As Office.UserPermission
    Set irmPermission = ActiveWorkbook.Permission
    Set irmUserPerm = irmPermission.Item(2)
    If irmUserPerm.Permission And Office.msoPermissionSave Then
        MsgBox "User " & irmUserPerm.UserId & _
            " has permission to save this document.", _
            vbInformation + vbOKOnly, "IRM Information"
    Else
        MsgBox "User " & irmUserPerm.UserId & _
            " does NOT have permission to save this document.", _
            vbInformation + vbOKOnly, "IRM Information"
    End If
    Set irmUserPerm = Nothing
    Set irmPermission = Nothing