LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Windows LOGON NAME - special case - account name different from folder name

Hi all excel gurus,

On my computer the LOGON NAME as it is showed in 'Start' or on the
login screen is different from the name of folder the data are stored.
My account name is 'Riso' but all windows related data are stored in
folder "C:\Documents and Settings\Riso_2". This state was obtained by
renaming account names and creating accounts with names that were used
before.

Actually, there are accounts:
Genius that is stored in C:\Documents and Settings\Riso
Riso that is stored in C:\Documents and Settings\Riso_2
John that is stored in C:\Documents and Settings\John

In welcome_user macro I want to show names Genius, Riso and John (in
order) when Genius, Riso or John (in order) opens the particular file.
In the code there is a line MsgBox "Hello " & xxxxxxxxxx.

If I use
Environ("UserName") or
wshnet.UserName or
logonNameVar
instead of xxxxxxxxxxxxx I recieve Riso, Riso_2 and John (in order)

(To make the list full) When I use Application.UserName I recieve
completelly different (and unrelated) info...no surprise.

For details see the attached illustrative sample code.

Well, It seems that UserName property contains the folder or original
name of the account instead of current name.

Is there any way how to get the actual name of the account?

Thank you in advance for any hint or ultimative answer that it is not
possible.

and thank you all for reading

------------
some info to sample code:
copy it to module and run macro show_boxes
all ways how to reach windows logon name are taken from posts in
microsoft.public.excel.programming group
====================illustrative SAMPLE CODE=====
Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long

Sub show_boxes()

Dim wshnet As Object
Set wshnet = CreateObject("WScript.Network")
MsgBox "The name of user is (WScript): " & wshnet.UserName

MsgBox "The name of user is (appl username): " & Application.UserName

MsgBox "The name of user is (environ username): " &
Environ("UserName")

Dim S As String
Dim L As Long
Dim R As Long
Dim logonNameVar As String
S = String$(255, " ")
L = Len(S)
R = GetUserName(S, L)
logonNameVar = Left(S, L - 1)
MsgBox "The name of user is (get user name): " & logonNameVar

End Sub

 
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
Code to logon to brokerage account aligatrjoe Excel Discussion (Misc queries) 3 January 14th 08 07:47 PM
special case of sumif delali Excel Worksheet Functions 4 March 24th 06 06:41 PM
special case of sumproduct delali Excel Worksheet Functions 2 March 24th 06 06:18 PM
Use Windows Network logon as password Spencer Hutton[_3_] Excel Programming 2 October 13th 04 01:17 PM
Getting Windows user (Account) from a VBA routine Jacques Brun Excel Programming 7 June 11th 04 11:35 PM


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