Guest
I would like to know if there is a way to get the user id, in a procedure, of the person who opens an Excel spreadsheet in order to display fields appropriate to the user. Thanks in advance.
Todd
Todd
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Dim sUser As String
sUser = UCase(Environ("username"))
[\code]
This utilizes the use of the USERNAME environment variable. Another way to accomplish this is using the API:
[code]
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetCurrentUser() As String
Dim lpBuff As String * 25
Dim ret As Long
ret = GetUserName(lpBuff, 25)
GetCurrentUser = UCase(Left(lpBuff, InStr(lpBuff, Chr(0)) - 1))
End Function