View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
iliace iliace is offline
external usenet poster
 
Posts: 229
Default Getting Logged in User Name in formula...

On Oct 29, 1:25 am, Kedar Agarkar wrote:
Hi,

I need to get the Windows logged in user name in the formula. Any hint
how to get this?
Thanks

- Kedar Agarkar



Using API calls:


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

Function UserName() As String
' Returns the name of the logged-in user
Dim Buffer As String * 100
Dim BuffLen As Long
BuffLen = 100
GetUserName Buffer, BuffLen
UserName = Left(Buffer, BuffLen - 1)
End Function


I got this from somewhere online. The usage is =PERSONAL.XLS!
UserName() or =PERSONAL.XLSB!UserName(), depending on file format.