---- Paste this in General section ----------- Private Declare Function apiGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long --- Copy this function and use it in your program ---------- Function getUserID() As String 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 getUserID = Left$(strUserName, lngLen - 1) Else getUserID = vbNullString End If End Function |