I am trying to use this piece of code:
http://www.chrisrae.com/vba/routines/getusername.html
' By Chris Rae, 14/6/99, 3/9/00.
Option Explicit
' This is used by GetUserName() to find the current user's
' name from the API
Declare Function Get_User_Name Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
Function GetUserName() As String
Dim lpBuff As String * 25
Get_User_Name lpBuff, 25
GetUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Function
When i try to access it by calling the GetUserName, i am getting an error stating:
"Compile Error: Constants, Fixed-Length Strings, Arrays, and Declare statements are not allowed as Public members of object modules"
Can someone give me a heads up?
Thanks.
http://www.chrisrae.com/vba/routines/getusername.html
' By Chris Rae, 14/6/99, 3/9/00.
Option Explicit
' This is used by GetUserName() to find the current user's
' name from the API
Declare Function Get_User_Name Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
Function GetUserName() As String
Dim lpBuff As String * 25
Get_User_Name lpBuff, 25
GetUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Function
When i try to access it by calling the GetUserName, i am getting an error stating:
"Compile Error: Constants, Fixed-Length Strings, Arrays, and Declare statements are not allowed as Public members of object modules"
Can someone give me a heads up?
Thanks.