Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unprotect on open
I need code that will check the network username and unprotect a worksheet
when the workbook opens. So on open it will check the username and then unlock the worksheets if it matches a list of approved users. If not, it will remain locked. I am using excel 2007. Thanks for all the help in advance. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unprotect on open
I use an Access database on our shared network to validate against. You will
need to add the appropriate references. Public Pass As Boolean Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer Public Sub UrIdentity() Pass = False Set TargetRange = Range("X1") Set cn = New ADODB.Connection DBFullName = "P:\Permanent_Data\Patrick\Security.mdb" TableName = "Authorized" cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & DBFullName & ";" Set rs = New ADODB.Recordset With rs .Open "SELECT * FROM " & TableName & " WHERE Emp LIKE '" & UCase(frmLogIn.txtUserNumb) & "'", cn, , , adCmdText For intColIndex = 0 To rs.Fields.Count - 1 ' the field names TargetRange.Offset(0, intColIndex).Value = rs.Fields(intColIndex).Name Next TargetRange.Offset(0, 0).CopyFromRecordset rs ' the recordset data End With rs.Close Set rs = Nothing cn.Close Set cn = Nothing If Range("X1").Value < "Emp" And Range("Y1").Value < "" Then Pass = True Else Pass = False End If Range("X1:Y1").ClearContents Range("A2").Select End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unprotect on open
On Aug 3, 10:46 am, wagz wrote:
I need code that will check the network username and unprotect a worksheet when the workbook opens. So on open it will check the username and then unlock the worksheets if it matches a list of approved users. If not, it will remain locked. I am using excel 2007. Thanks for all the help in advance. Environ("Username") will return the name of the user. You could use that to validate against a source of your choosing. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I unprotect a spreadsheet? | Excel Worksheet Functions | |||
unprotect workbook | Excel Discussion (Misc queries) | |||
Unprotect a worksheet | New Users to Excel | |||
Unprotect worksheet via VBA | Excel Worksheet Functions | |||
Unprotect | Excel Discussion (Misc queries) |