View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Limit Files via VBA not folder rights or permissions

Private Declare Function apiGetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nsize As Long) As Long

Sub GetUserNameTest()
MsgBox 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

--
Regards,
Tom Ogilvy

"Curt" wrote in message
...
Good morning,

Do you have any ideas as for securing a workbook based upon userid. I
believe each computer contains a API, MPR or DLL file which the current

user
of that machines userid resides. I would like to be able limit access to
workbook based upon userid listed within the workbook.

Reason, the file contains sensitive information but needs to be accesible

to
many. So, if someone who has rights to the folder saves the file and

shares
it with someone else. That someone else will not have acces to the file

with
out me specifying them somewhere in the VBA code or WB.

Is this possible?