View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default How do i retrieve Windows User name on a excel sheet?

Just to clarify a little further, it doesn't all go there. This bit has to go
in a module in 'This Workbook'

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

Id go for something simpler.

Range("A1").Value = Environ("Username")

Mike



"Luke M" wrote:

As clarification, Daniel's code needs to go in the VBA editor. Right click
the sheet tab, select view code, and then paste the code in.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Sirigeri Goutam Shetty" wrote:

I'm trying to retrieve windows user name or log in name on a excel sheet with
certain commands. But i'm not sure if excel supports this feature.

Currently i'm using MS Office 2003 and WindowsXP professional edition.