Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15
Default Getting Logged in User Name in formula...

Hi,

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

- Kedar Agarkar

  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 110
Default Getting Logged in User Name in formula...

Hello Kedar Agarkar
You will need a little VBA to achieve this.
Insert a new module into your workbook VBAProject and paste the following:
Function GetUSerLogged()
On Error Resume Next
GetUSerLogged = CreateObject("WScript.Network").UserName
If Err < 0 Then
GetUSerLogged = "Not available"
Err.Clear
On Error GoTo 0: End If
End Function

Then in your spreadsheet, formulae:
=GetUserLogged()

HTH
Cordially
Pascal


"Kedar Agarkar" a écrit dans le message de news:
...
Hi,

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

- Kedar Agarkar



  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Getting Logged in User Name in formula...

Msgbox Environ("Username")

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Kedar Agarkar" wrote in message
ps.com...
Hi,

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

- Kedar Agarkar



  #4   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15
Default Getting Logged in User Name in formula...

Thanks Pascal and Bob, shall be taking clues from your replies.
Thanks for your time.

- Kedar

  #5   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,365
Default Getting Logged in User Name in formula...

If it were me, I'd use papau's code, just changing the one line that uses the
Script object to use the Environ("username") [ GetUSerLogged =
Environ("username") ] form that Bob Phillips provided. Environ is going to
work on any Excel setup, whereas there's a possibility of failure with the
script on some machines, plus scripting is external to Excel and is slower to
return the result. papau's code slightly modified:

Function GetUSerLogged()
On Error Resume Next
GetUSerLogged = Environ("username")
If Err < 0 Then
GetUSerLogged = "Not available"
Err.Clear
End If
On Error GoTo 0
End Function


"Kedar Agarkar" wrote:

Thanks Pascal and Bob, shall be taking clues from your replies.
Thanks for your time.

- Kedar




  #6   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Getting Logged in User Name in formula...

In other words, if it were you you would use my code <bg?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"JLatham" <HelpFrom @ Jlathamsite.com.(removethis) wrote in message
...
If it were me, I'd use papau's code, just changing the one line that uses
the
Script object to use the Environ("username") [ GetUSerLogged =
Environ("username") ] form that Bob Phillips provided. Environ is going
to
work on any Excel setup, whereas there's a possibility of failure with the
script on some machines, plus scripting is external to Excel and is slower
to
return the result. papau's code slightly modified:

Function GetUSerLogged()
On Error Resume Next
GetUSerLogged = Environ("username")
If Err < 0 Then
GetUSerLogged = "Not available"
Err.Clear
End If
On Error GoTo 0
End Function


"Kedar Agarkar" wrote:

Thanks Pascal and Bob, shall be taking clues from your replies.
Thanks for your time.

- Kedar




  #7   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,365
Default Getting Logged in User Name in formula...

That's pretty much the bottom line <g ... Your method of username retrieval
with the code segment papau set up to get it back to the user, even to
including the error trapping for what should be an impossible error.

"Bob Phillips" wrote:

In other words, if it were you you would use my code <bg?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"JLatham" <HelpFrom @ Jlathamsite.com.(removethis) wrote in message
...
If it were me, I'd use papau's code, just changing the one line that uses
the
Script object to use the Environ("username") [ GetUSerLogged =
Environ("username") ] form that Bob Phillips provided. Environ is going
to
work on any Excel setup, whereas there's a possibility of failure with the
script on some machines, plus scripting is external to Excel and is slower
to
return the result. papau's code slightly modified:

Function GetUSerLogged()
On Error Resume Next
GetUSerLogged = Environ("username")
If Err < 0 Then
GetUSerLogged = "Not available"
Err.Clear
End If
On Error GoTo 0
End Function


"Kedar Agarkar" wrote:

Thanks Pascal and Bob, shall be taking clues from your replies.
Thanks for your time.

- Kedar





  #9   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
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.

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
Auto Updating the Logged in User DCHims Excel Discussion (Misc queries) 1 September 4th 07 07:58 PM
Creating an Excel Database for my Logged Time MsSnowy Excel Worksheet Functions 2 August 9th 07 07:46 PM
Sharing Problems- users keep reappearing even though logged out. Gai Excel Discussion (Misc queries) 0 February 23rd 07 02:53 AM
How do you reference the logged on user name in excel? Taurus Excel Discussion (Misc queries) 2 January 24th 06 07:38 PM
help with a formula (New User) detlghtpd Excel Discussion (Misc queries) 3 March 25th 05 06:03 PM


All times are GMT +1. The time now is 09:10 PM.

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"