Ross,
You can use a function like the following:
Function MyUserName() As String
MyUserName = Environ("UserName")
End Function
I have seen on rare occassion the Environ return an empty string. The
following code is a wee bit more complex but will always work.
Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
( _
ByVal lpBuffer As String, _
nSize As Long) As Long
Function MyUserNameAPI() As String
Dim UName As String
Dim L As Long
Dim R As Long
L = 255
UName = String$(L, vbNullChar)
R = GetUserName(UName, L)
MyUserNameAPI = Left(UName, L - 1)
End Function
--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
"Ross Culver" wrote in message
...
Could someone please tell me how I can find out what my network login name
is in VBA?
I do it all the time in .net, but there's no 'Import' in vba and I haven't
a clue what to reference to be able to get the current user's network name
(not the application username).
I thought I almost had it with:
Set orootDSE = GetObject("LDAP://rootDSE")
MsgBox orootDSE.get("currentuid")
but 'currentuid' isn't correct.
Thanks,
Exasperated