ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Start up security (https://www.excelbanter.com/excel-programming/412718-start-up-security.html)

will07

Start up security
 
Is it possible to enter code into an excel file that looks for a network user
name as the file opens. If your user name is not on the network, then the
file will not open. I realise that security for Excel is dodgy at the best
of times, but it is a start.

I have set range passwords for the worksheets, but need to prevent the file
from opening.

Thanks

steven

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

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



All times are GMT +1. The time now is 03:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com