Forum Discussion
ChrisPWC
Jul 26, 2021Copper Contributor
Get the logged in users email and manager
Hi
I need to get the currently logged in users email and manager. I have the username as per code below.
Sub GetLoggedInUserCredentials()
'Declare variables
Dim strUserName As String
Dim strPrincipal As String
Dim strUserEmail As String
'Get system logged in user name, manager and principal
strUserName = Environ("Username") 'This works
strPrincipal = Environ("Manager") '??? not sure what must go here, not sure Environ is the right thing looking to use Azure AD
strUserEmail = Environ("UserEmail") '???
Worksheets("Setup").Range("N17") = strUserName 'This works
Worksheets("Setup").Range("N20") = strPrincipal
Worksheets("Setup").Range("N21") = strUserEmail
End Sub
3 Replies
Email address and Manager aren't environment variables.