Granted permission to two users. : Workbook Permission « Excel « VBA / Excel / Access / Word






Granted permission to two users.

 

Sub AddUsers()
    Dim myPermission As Office.Permission, usr As Office.UserPermission
    Set myPermission = ThisWorkbook.Permission
    myPermission.RemoveAll
    myPermission.Add "someone@hotmail.com", MsoPermission.msoPermissionView
    Set usr = myPermission.Add("ExcelDemo@hotmail.com", MsoPermission.msoPermissionView)
    usr.Permission = MsoPermission.msoPermissionPrint Or MsoPermission.msoPermissionExtract
    Set usr = myPermission("ExcelDemo@hotmail.com")
    usr.ExpirationDate = Date + 1
End Sub

 








Related examples in the same category

1.Workbook permissions removed -- workbook access is no longer restricted through IRM.
2.'Show User Permissions
3.Workbook permissions restricted
4.See VBA Immediate window for a list of permissions and users.