Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default environ username vs. application username

i am using the following codes to obtain a user name:

Function ThisUser()
ThisUser = Environ("UserName")
End Function
Function MyName()
MyName = Application.UserName
End Function

both work, ThisUser returns my login id (ex. jat) and MyName returns my name
that i have entered in Excel's Personalization area (ex. jat man)

What i would like is to get the MyName to be retrieved from my actual
profile. When i go to Start, my name shows at the top (first last name), and
that is set up when my profile is created. How do i retrieve this in a macro?

jat

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default environ username vs. application username

Dear

Try the below and feedback...

Dim objSysInfo, objUser
Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
MsgBox objUser.displayName

If this post helps click Yes
---------------
Jacob Skaria


"jatman" wrote:

i am using the following codes to obtain a user name:

Function ThisUser()
ThisUser = Environ("UserName")
End Function
Function MyName()
MyName = Application.UserName
End Function

both work, ThisUser returns my login id (ex. jat) and MyName returns my name
that i have entered in Excel's Personalization area (ex. jat man)

What i would like is to get the MyName to be retrieved from my actual
profile. When i go to Start, my name shows at the top (first last name), and
that is set up when my profile is created. How do i retrieve this in a macro?

jat

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default environ username vs. application username

i put the code provided in the Private Sub Workbook_Open event with the rest
of the open events...

Error message received is:
Run-time error '-2147023541 (8007054b)':
Automation error
The specified domain either does not exist or could not be contacted.

i press Debug, and the macro opens with the following line highlighted:
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)

jat




"Jacob Skaria" wrote:

Dear

Try the below and feedback...

Dim objSysInfo, objUser
Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
MsgBox objUser.displayName

If this post helps click Yes
---------------
Jacob Skaria


"jatman" wrote:

i am using the following codes to obtain a user name:

Function ThisUser()
ThisUser = Environ("UserName")
End Function
Function MyName()
MyName = Application.UserName
End Function

both work, ThisUser returns my login id (ex. jat) and MyName returns my name
that i have entered in Excel's Personalization area (ex. jat man)

What i would like is to get the MyName to be retrieved from my actual
profile. When i go to Start, my name shows at the top (first last name), and
that is set up when my profile is created. How do i retrieve this in a macro?

jat

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default environ username vs. application username

I added the code to the Workbook Open events. when the workbook is opened, i
get the following error:

Run-time error '-2147023541 (8007054b))':
Automation error
The specified domain either does not exist or could not be contacted.

when i press the debug button, i the code is displayed with the following
highlighted:
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)

jat


"jatman" wrote:

i am using the following codes to obtain a user name:

Function ThisUser()
ThisUser = Environ("UserName")
End Function
Function MyName()
MyName = Application.UserName
End Function

both work, ThisUser returns my login id (ex. jat) and MyName returns my name
that i have entered in Excel's Personalization area (ex. jat man)

What i would like is to get the MyName to be retrieved from my actual
profile. When i go to Start, my name shows at the top (first last name), and
that is set up when my profile is created. How do i retrieve this in a macro?

jat

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default environ username vs. application username

This works only if you are logged in to a network domain.

If this post helps click Yes
---------------
Jacob Skaria


"jatman" wrote:

I added the code to the Workbook Open events. when the workbook is opened, i
get the following error:

Run-time error '-2147023541 (8007054b))':
Automation error
The specified domain either does not exist or could not be contacted.

when i press the debug button, i the code is displayed with the following
highlighted:
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)

jat


"jatman" wrote:

i am using the following codes to obtain a user name:

Function ThisUser()
ThisUser = Environ("UserName")
End Function
Function MyName()
MyName = Application.UserName
End Function

both work, ThisUser returns my login id (ex. jat) and MyName returns my name
that i have entered in Excel's Personalization area (ex. jat man)

What i would like is to get the MyName to be retrieved from my actual
profile. When i go to Start, my name shows at the top (first last name), and
that is set up when my profile is created. How do i retrieve this in a macro?

jat

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
Username Oldjay Excel Programming 13 April 25th 08 07:50 PM
Environ("username") riso Excel Programming 11 March 9th 07 10:43 AM
Application.UserName Question HROBERTSON Excel Discussion (Misc queries) 5 January 8th 07 05:01 PM
Including Environ Username in Cell swieduwi Excel Worksheet Functions 9 March 30th 06 04:43 PM
application.username Donald Stockton Excel Programming 7 February 27th 04 07:39 PM


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

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

About Us

"It's about Microsoft Excel"