Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How do i retrieve Windows User name on a excel sheet?

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.


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 105
Default How do i retrieve Windows User name on a excel sheet?

From the internet (www.mrexcel.com) :

Option Explicit
' This is used by GetUserName() to find the current user's
' name from the API
Declare Function Get_User_Name Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
Function GetUserName() As String
Dim lpBuff As String * 25

Get_User_Name lpBuff, 25
GetUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Function

Sub test()
[A1] = GetUserName
End Sub

Daniel


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.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default How do i retrieve Windows User name on a excel sheet?

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.


  #4   Report Post  
Posted to microsoft.public.excel.misc
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.


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default How do i retrieve Windows User name on a excel sheet?

You can't do it directly from a formula -- you need VBA code. User

Function UserName() As String
UserName = Environ("UserName")
End Function

Then, call that function from a worksheet cell:

=UserName()

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 12 Nov 2008 05:00:02 -0800, Sirigeri Goutam Shetty <Sirigeri
Goutam 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
to retrieve a particular value from excel sheet refina New Users to Excel 1 June 14th 08 08:55 PM
Retrieve Data from one sheet to another karstens Excel Worksheet Functions 0 July 11th 06 09:49 PM
How do I import Names of Windows files into an Excel Spread sheet solrac1956 Excel Worksheet Functions 3 June 28th 05 07:47 PM
Windows XP Excell - sheet 1 / shhet 2 / sheet 3... Jacques Poulin Excel Discussion (Misc queries) 1 February 25th 05 03:09 AM
Function that gives Windows current user name? Petu Excel Worksheet Functions 2 December 8th 04 10:33 AM


All times are GMT +1. The time now is 06:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"