query system username
Kevin
Private Declare Function apiGetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nsize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX < 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function
Sub GetUserNameTest()
MsgBox fOSUserName
End Sub
Regards
Trevor
"Kevin Perez" wrote in message
...
Hello,
How can I return the system username either in VBA or a
function?
I've written a macro to enable several different users to
input data. I want to provide a measure of security so
that only select users can activate the macro.
Thanks.
Kevin
|