Private Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As Long Private Declare Function GetUserName Lib "ADVAPI32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Public Function GetCurrentUserName() As String On Error GoTo Err_GetCurrentUserName Dim lpBuff As String * 25 Dim ret As Long, Username As String ret = GetUserName(lpBuff, 25) Username = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1) GetCurrentUserName = Username & "" Exit_GetCurrentUserName: Exit Function Err_GetCurrentUserName: MsgBox Err.Description Resume Exit_GetCurrentUserName End Function