Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code to logon to brokerage account | Excel Discussion (Misc queries) | |||
special case of sumif | Excel Worksheet Functions | |||
special case of sumproduct | Excel Worksheet Functions | |||
Use Windows Network logon as password | Excel Programming | |||
Getting Windows user (Account) from a VBA routine | Excel Programming |