Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
What is the function for system to capture the username | Excel Discussion (Misc queries) | |||
display what the function mean | Excel Worksheet Functions | |||
how do I display username, current time & date on the status bar | Excel Programming | |||
if function display | Excel Worksheet Functions | |||
display data from a website in excel that requires a username/password | Excel Programming |