Code Snippet Details

<- Back to List


Language
VBA
Description
Get User ID
Code
Option Explicit Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private mstrUserName As String Sub GetUserID() mstrUserName = String(254, Chr(0)) GetUserName mstrUserName, 254 mstrUserName = Left(mstrUserName, InStr(1, mstrUserName, Chr(0)) - 1) Debug.Print mstrUserName End Sub