Table of contents
TOC
Collapse the table of content
Expand the table of content

UserPermission Object (Office)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Associates a set of permissions on the active document with a single user and an optional expiration date. Represents a member of the active document's Permission collection.

Remarks

Use the Add method of the Permission object to grant specific permissions on the active document to a new user, with an optional expiration date. Use the Remove method of the UserPermission object to remove a user and the user's permissions.

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 determines whether the active document has restricted permissions, then lists users and their assigned permissions by returning the UserId, Permission, and ExpirationDate properties of each UserPermission in the document's Permission collection.

 Dim irmPermission As Office.Permission 
 Dim irmUserPerm As Office.UserPermission 
 Dim strIRMInfo As String 
 Set irmPermission = ActiveWorkbook.Permission 
 If irmPermission.Enabled Then 
 For Each irmUserPerm In irmPermission 
 strIRMInfo = strIRMInfo & irmUserPerm.UserId & vbCrLf & _ 
 " - Permissions: " & irmUserPerm.Permission & vbCrLf & _ 
 " - Expiration Date: " & irmUserPerm.ExpirationDate & vbCrLf 
 Next 
 MsgBox strIRMInfo, _ 
 vbInformation + vbOKOnly, "IRM Information" 
 Else 
 MsgBox "This document is not restricted.", _ 
 vbInformation + vbOKOnly, "IRM Information" 
 End If 
 Set irmUserPerm = Nothing 
 Set irmPermission = Nothing 

Methods

Name
Remove

Properties

Name
Application
Creator
ExpirationDate
Parent
Permission
UserId

See also

Other resources

Object Model Reference

© 2018 Microsoft