Programmatic user id in Excel
Programmatic user id in Excel
(OP)
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
RE: Programmatic user id in Excel
Dim sUser As String
sUser = UCase(Environ("username"))
This utilizes the use of the USERNAME environment variable. Another way to accomplish this is using the API:
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
Hope this helps...
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.