R
RonB
Guest
I have VBA code from developer library to get a user name
ie
Function FindUserName() As String
' This procedure uses the Win32API function GetUserName
' to return the name of the user currently logged on to
' this machine. The Declare statement for the API function
' is located in the Declarations section of this module.
Dim strBuffer As String
Dim lngSize As Long
strBuffer = String(100, " ")
lngSize = Len(strBuffer)
If GetUserName(strBuffer, lngSize) = 1 Then
FindUserName = Left(strBuffer, lngSize)
Else
FindUserName = "Name not available"
End If
End Function
However this code requires 'Declare statement'
To ease my life - can anyone give me an example of this 'Declare statement 'code
ie
Function FindUserName() As String
' This procedure uses the Win32API function GetUserName
' to return the name of the user currently logged on to
' this machine. The Declare statement for the API function
' is located in the Declarations section of this module.
Dim strBuffer As String
Dim lngSize As Long
strBuffer = String(100, " ")
lngSize = Len(strBuffer)
If GetUserName(strBuffer, lngSize) = 1 Then
FindUserName = Left(strBuffer, lngSize)
Else
FindUserName = "Name not available"
End If
End Function
However this code requires 'Declare statement'
To ease my life - can anyone give me an example of this 'Declare statement 'code