Getting the computer user name

Jaymin

Registered User.
Local time
Today, 16:02
Joined
Oct 24, 2011
Messages
70
Hope someone can help me, i want to get access to tell me who has loged onto the computer, i know in excel there is a code
Code:
GetXLUserName
this gives you there login name,

Peter :)
 
You may try Environ("USERNAME")
 
The weakness with the username environment variable is that it can be changed by the user.

This is more reliable:
CreateObject("wscript.network").UserName

Best encapsulated in a function so the wscript object is destroyed after returning the value.
 
Jdraw and Galaxiom,
Thank you for your replies.
Galaxiom can you show me how to program what you have suggested
encapsulated in a function so the wscript object is destroyed after returning the value
Peter
 
If you want to get to it from the whole project (including queries) put it in a Standard Module.

Code:
Public Function fUserName()
 
   fUserName = CreateObject("wscript.network").UserName
 
End Function

Use it like this in subs:
somevariable = fUserName
 
Galaxiom,
Thank you for your help and time, also a quick responce.
Peter
 

Users who are viewing this thread

Back
Top Bottom