|
-
September 4th, 2001, 09:13 PM
#1
Picking up currently logged in user name with VBA
I need a way to pick up the name the currently logged in user. The OS is windows NT 4 and the code will form part of an Excel module. It doesn't matter where the name comes from, if someone has a way of extracting the information from the registry I can adapt the code to suite my system. Thanks in advance.
-
September 5th, 2001, 01:31 AM
#2
Re: Picking up currently logged in user name with VBA
This will do the job
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (byval
lpBuffer as string, nSize as Long) as Long
Function GetUser() as string
Dim lpUserID as string
Dim nBuffer as Long
Dim Ret as Long
lpUserID = string(25, 0)
nBuffer = 25
Ret = GetUserName(lpUserID, nBuffer)
If Ret <> 0 then
GetUser = lpUserID
End If
End Function
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
-
September 5th, 2001, 03:33 AM
#3
Re: Picking up currently logged in user name with VBA
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|