Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You may want to consider using a helper workbook that checks the credentials of
the user and if that's ok, it would open the real workbook. If you give that real workbook a nice password, you could include the password in the code in the helper workbook (and protect that workbook's project). I'd create the helper workbook with two sheets. One that has instructions to the user and one that has the list of valid users. Then I'd hide that second sheet. It won't stop the very interested, but it would stop most(???). I based my validation on Chip's post: Option Explicit Private Sub Workbook_Open() Dim UserName As String Dim V As Variant dim myPWD as string dim wkbk as workbook UserName = Environ("username") myPWD = "hi" On Error Resume Next V = Application.Match(UserName, thisworkbook.worksheets("UserNames").range("a:a"), 0) On Error Goto 0 If IsError(V) = True Then Msgbox "You're not authorized!" Else Set wkbk = Workbooks.Open(Filename:="C:\my documents\excel\book1.xls", _ Password:=myPWD) wkbk.RunAutoMacros which:=xlAutoOpen end if ThisWorkbook.Close savechanges:=False End Sub The users would always have to open this helper workbook first. If they disabled macros, they'd see your instruction page. If they weren't authorized, they'd see the msgbox. If they enabled macros and were authorized, the helper workbook would open the real workbook and then the helper workbook would close itself. Tim wrote: I wish to create a small security trap whereby a user cannot access a file unless his/her username is within a named range. I know Excel security is basic, but thats the level I'm at. So if the user is not named in a named range a dialog box appears "No access" etc and the file closes. The username I will compare against the username on the xl 2007 panel. If the username matches open the file as normal -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Grab Open Outlook Username from Excel | Excel Programming | |||
How to get username during workbooks.open macro | Excel Programming | |||
Windows API to get network username of person with file open | Excel Programming | |||
Windows API to get network username of person with file open | Excel Programming | |||
XMLHTTP.OPEN + PASSWORD + USERNAME | Excel Programming |