Discussion Locked

VB API Call & Excel 2000

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How can I make this API call & function that DOES work in MSAccess 2000 on Win2000 work in Excel2000, same platform?

Declare Function DeclareGetLogin Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function GetUserName() As String
Dim lngLen As Long
Dim strBuf As String

strBuf = Space(255)
lngLen = 255
If CBool(DeclareGetLogin(strBuf, lngLen)) Then
GetUserName = Left$(strBuf, lngLen - 1)
Else
GetUserName = ""
End If

End Function

3 replies

by sheryl v

Poster rated this answer.
thrid one worked, it was a variation on what I had, but it actaully works so thank you!

This discussion is closed to new replies.