G
Gimp
Hello -
I have found the following code from this group. It works, to the
point that a message box pops with my user ID. But I am not sure if
this is what I need or if it is how to modify it as a login
varification to prevent other users from opening or viewing an excel
sheet.
Private Declare Function apiGetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nsize As Long) As
Long
Sub GetUserNameTest()
MsgBox "I am " & fOSUserName
End Sub
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function
So, if I am not me, then I get access denied message...that is what
I'm looking for...is this code a good start, if it is how would I
modify to close the sheet if I'm not who I say I am...if it is not the
best way, then any ideas on how to do this?
Thanks..
I have found the following code from this group. It works, to the
point that a message box pops with my user ID. But I am not sure if
this is what I need or if it is how to modify it as a login
varification to prevent other users from opening or viewing an excel
sheet.
Private Declare Function apiGetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nsize As Long) As
Long
Sub GetUserNameTest()
MsgBox "I am " & fOSUserName
End Sub
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function
So, if I am not me, then I get access denied message...that is what
I'm looking for...is this code a good start, if it is how would I
modify to close the sheet if I'm not who I say I am...if it is not the
best way, then any ideas on how to do this?
Thanks..