Thread: Username
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Username

Alvin,

Try this

Public Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long

Public Function UserName() As String
Dim sName As String * 256
Dim cChars As Long
cChars = 256
If GetUserName(sName, cChars) Then
UserName = Left(sName, cChars - 1)
End If
End Function


--

HTH

RP

"Alvin Hansen" wrote in message
...
Hi!!
I use this
name = Environ("username")
Its work allright on a standalone PC but when i try on a PC there loog on

to
a server then username is the name there been used when Windoes was

install
first time. And not the "real" user

Hope someone can help

Best regards alvin