Thread: Get NT 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 Get NT Username

No built-in, but you can do it with a UDF.

Here is a function to do it

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

The worksheet cell could then use

=UserName()



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steven Pugh" wrote in message
...
Hi,

I trying to create a spreadsheet that when you go in, depending on what

user
you are, you can see different worksheets sheets.

I figure I can do this, if I could first determine the user that is logged
on via on our NT network.

I there a formula / function in ExcelXP that can do this


Regards
Steven