DomainName Property

Microsoft Office Visual Basic

DomainName Property

Returns the domain and user name of the specified SharedWorkspaceMember in the format domain\user. Read-only String.

expression.DomainName

expression    Required. An expression that returns a SharedWorkspaceMember object.

Example

The following example extracts the domain name from the DomainName property of each shared workspace member and lists members who belong to the "MyCompany" domain.

        Dim swsMember As Office.SharedWorkspaceMember
    Dim strDomain As String
    Dim strMemberList As String
    For Each swsMember In ActiveWorkbook.SharedWorkspace.Members
        strDomain = UCase(Left(swsMember.DomainName, _
            InStr(swsMember.DomainName, "\") - 1))
        If strDomain = "MYCOMPANY" Then
            strMemberList = strMemberList & swsMember.Name & vbCrLf
        End If
    Next
    MsgBox strMemberList, vbInformation + vbOKOnly, _
        "Members in the MYCOMPANY Domain"
    Set swsMember = Nothing