Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Function to display username/networkname

I've been looking all over and I know it's possible, but I can't seem to
figure this one out.

I want Excel to display the Network name (windows logon ID) in a cell. I'd
like this to be a function, so I can do IF statements with it.

Any help greatly appriciated!
Hendrik
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default Function to display username/networkname

Try the following codes
Public Function GetUsername() As String

On Error Resume Next


Dim objScript As Object
Set objScript = CreateObject("WScript.NetWork")
If Not objScript Is Nothing Then
GetUsername = objScript.USERNAME
End If
Set objScript = Nothing


End Function
Public Function GetUserDisplayName() As String
'--------------------8<----------------------
Set oADSystemInfo = CreateObject("ADSystemInfo")
' get user object
Set oADsUser = GetObject("LDAP://" & oADSystemInfo.USERNAME)
' get full name of the current user
GetUserDisplayName = oADsUser.displayname
'--------------------8<----------------------
End Function

"Hendrik.Kleine" wrote:

I've been looking all over and I know it's possible, but I can't seem to
figure this one out.

I want Excel to display the Network name (windows logon ID) in a cell. I'd
like this to be a function, so I can do IF statements with it.

Any help greatly appriciated!
Hendrik

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Function to display username/networkname

Thanks Chris, works perfectly!

"Chris" wrote:

Try the following codes
Public Function GetUsername() As String

On Error Resume Next


Dim objScript As Object
Set objScript = CreateObject("WScript.NetWork")
If Not objScript Is Nothing Then
GetUsername = objScript.USERNAME
End If
Set objScript = Nothing


End Function
Public Function GetUserDisplayName() As String
'--------------------8<----------------------
Set oADSystemInfo = CreateObject("ADSystemInfo")
' get user object
Set oADsUser = GetObject("LDAP://" & oADSystemInfo.USERNAME)
' get full name of the current user
GetUserDisplayName = oADsUser.displayname
'--------------------8<----------------------
End Function

"Hendrik.Kleine" wrote:

I've been looking all over and I know it's possible, but I can't seem to
figure this one out.

I want Excel to display the Network name (windows logon ID) in a cell. I'd
like this to be a function, so I can do IF statements with it.

Any help greatly appriciated!
Hendrik

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Function to display username/networkname

I might be pushing this a bit, but I'd like to record the date and time the
user previously opened the workbook.

A1=The username function you provided.

=IF(A1="Username1",NOW(),"Unknown")

This formula records the time when the file is openend. However, whenever
this user makes a change and the workbook is recalculated, the "NOW" time is
updated. Also, when "Username2" opens the workbook, the formula for
"Username1" will change to "Unkown"

Would you have any thoughts on how to "freeze" the formula?

I understand if this is asking too much :)

Regards,
Hendrik

"Chris" wrote:

Try the following codes
Public Function GetUsername() As String

On Error Resume Next


Dim objScript As Object
Set objScript = CreateObject("WScript.NetWork")
If Not objScript Is Nothing Then
GetUsername = objScript.USERNAME
End If
Set objScript = Nothing


End Function
Public Function GetUserDisplayName() As String
'--------------------8<----------------------
Set oADSystemInfo = CreateObject("ADSystemInfo")
' get user object
Set oADsUser = GetObject("LDAP://" & oADSystemInfo.USERNAME)
' get full name of the current user
GetUserDisplayName = oADsUser.displayname
'--------------------8<----------------------
End Function

"Hendrik.Kleine" wrote:

I've been looking all over and I know it's possible, but I can't seem to
figure this one out.

I want Excel to display the Network name (windows logon ID) in a cell. I'd
like this to be a function, so I can do IF statements with it.

Any help greatly appriciated!
Hendrik

  #5   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Function to display username/networkname

Just another way:

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

HTH

"Hendrik.Kleine" wrote:

I've been looking all over and I know it's possible, but I can't seem to
figure this one out.

I want Excel to display the Network name (windows logon ID) in a cell. I'd
like this to be a function, so I can do IF statements with it.

Any help greatly appriciated!
Hendrik

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
What is the function for system to capture the username Dave VB logic for excel Excel Discussion (Misc queries) 4 March 7th 09 07:33 AM
display what the function mean T.C.B. Excel Worksheet Functions 1 August 31st 07 04:20 AM
how do I display username, current time & date on the status bar Gary Tan Excel Programming 4 July 25th 06 06:29 AM
if function display Cyberjack Excel Worksheet Functions 1 January 20th 05 03:46 PM
display data from a website in excel that requires a username/password John Williams[_5_] Excel Programming 2 November 19th 04 02:34 PM


All times are GMT +1. The time now is 04:05 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"