UserId Property

Microsoft Office Visual Basic

UserId Property

Returns the email name of the user whose permissions on the active document are determined by the specified UserPermission object. Read-only String.

expression.UserId

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 UserID property returns the name in email form of the user whose permissions are determined by the specified UserPermission object.

Example

The following example lists the users who have permissions on the active document.

        Dim irmPermission As Office.Permission
    Dim irmUserPerm As Office.UserPermission
    Dim strUsers As String
    Set irmPermission = ActiveWorkbook.Permission
    If irmPermission.Enabled Then
        For Each irmUserPerm In irmPermission
            strUsers = strUsers & irmUserPerm.UserId & vbCrLf
        Next
        MsgBox strUsers, _
            vbInformation + vbOKOnly, "IRM Information"
    Else
        MsgBox "Permissions are not enabled for this document.", _
            vbInformation + vbOKOnly, "IRM Information"
    End If
    Set irmUserPerm = Nothing
    Set irmPermission = Nothing