Share via


Permission Property

MsoPermission

MsoPermission can be one of the following msoPermission constants.
msoPermissionView (1)
msoPermissionRead (1)
msoPermissionEdit (2)
msoPermissionSave (4)
msoPermissionExtract (8)
msoPermissionChange (15)
msoPermissionPrint (16)
msoPermissionObjectModel (32)
msoPermissionFullControl (64)

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.

  • The msoPermissionView or msoPermissionRead option corresponds to the Read... option in the user interface.
  • The msoPermissionExtract option corresponds to the Allow users with read access to copy content option in the user interface.
  • The msoPermissionChange option corresponds to the Change... option in the user interface. The msoPermissionChange option represents the sum of msoPermissionView + msoPermissionEdit + msoPermissionSave + msoPermissionExtract and allows users to view, edit, copy, and save, but not print, the document.
  • The msoPermissionPrint option corresponds to the Print content option in the user interface.
  • The msoPermissionObjectModel option corresponds to the Access content programmatically option in the user interface and allows users to access the document programmatically through its object model. Users without msoPermissionObjectModel cannot use the object model to determine their own rights, since programmatic access is disabled.

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

Applies to | UserPermission Object