If I recall correctly, older versions of Windows (98? ME?) don't
have the "username" environ variable. The API method will work in
any version.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"R. Choate" wrote in message
...
What I needed was the simple
strUser = Environ("username")
that yields whatever the user is logged on as. I think this is
likely the same info returned by the long API call you
referenced,
but I'm not sure.
Thanks,
--
RMC,CPA
"Gary L Brown" wrote in message
...
Not sure exactly what you want but the following
user-defined-function can be
used to get the Network User Name. Just run the 'ShowNetName'
macro...
'/=================================================/
Private Declare Function GetUserName Lib "ADVAPI32.DLL" _
Alias "GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
'/=================================================/
Sub ShowNetName()
MsgBox GetNetworkUserName
End Sub
'/=================================================/
Private Function GetNetworkUserName() As String
Dim strUserName As String
On Error GoTo Err_GetNetworkUserName
strUserName = String(255, 0)
GetUserName strUserName, Len(strUserName)
GetNetworkUserName = Application.WorksheetFunction. _
Clean(strUserName)
Exit_GetNetworkUserName:
Exit Function
Err_GetNetworkUserName:
GetNetworkUserName = ""
Resume Exit_GetNetworkUserName
End Function
'/=================================================/
HTH,
--
Gary Brown
If this post was helpful, please click the ''Yes'' button next
to ''Was this
Post Helpfull to you?''.
"R. Choate" wrote:
Can I initialize the % sign as a variable in code to identify
and use to indicate the user id of the user who is running the
code
on
their station? For example X = %. or something like that.
Thanks,
--
RMC,CPA