PDA

View Full Version : Sleeper: Something is missing HELP PLEASE!



GregM
01-18-2005, 09:11 AM
My macro works fine {except} when the sheet that is named and saved is reopened for future editing the locked cells can be selected. My original template still works fine though.

The cells are still locked and cannot be edited but should not be selectable. I verify that the sheet is still protected.

I unprotect it and re-protect it to find the SELECT LOCKED CELLS is enabled or set to TRUE.

Somehow I presume I need to set SELECT LOCKED CELLS to off or false.

Also, I had seen earlier in my search where someone was using a text file to maintain the counter data (I can't find that thread anymore though). If someone could share with me how to do that I'd be grateful.

Any help to get me beyond this hump will be greatly appreciated.

Best regards, GregM



Sub saving()
Dim tempName As String
tempName = ActiveWorkbook.Name
If tempName <> "!PAGE ONE_InvTemplate.xls" Then
Exit Sub
End If
' Sheets("Simple Invoice").Protect userinterfaceonly:=True
ActiveSheet.Unprotect Password:="x"
[M12].Value = [M12].Value + 1
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
ActiveSheet.Protect Password:="x"
Range("C9").Select
Application.DisplayAlerts = False
ThisWorkbook.SaveAs ("C:\Documents and Settings\Marisa\Desktop\Invoices\!PAGE ONE_InvTemplate.xls")
Application.DisplayAlerts = True
Dim invName As String
invName = InputBox("What is the Invoice Name?")
Range("C9").Value = invName
invName = invName + "_" + CStr([M12].Value)
ThisWorkbook.SaveAs ("C:\Documents and Settings\Marisa\Desktop\Invoices\" & invName & ".xls")
End Sub

Kieran
01-18-2005, 08:28 PM
The Protect method parameter UserInterfaceOnly will affect the result, however the property is not stored when the worksheet is closed and opened.

You will need to install an auto open macro for the workbook or similar for it to have effect.



ActiveSheet.Protect Password:="x", UserInterfaceOnly:=True

GregM
01-18-2005, 10:16 PM
Thanx for the input Kieran. So, shouldn't the following input to my current sub serve the purpose you mentioned?


Sub saving()
Dim tempName As String
tempName = ActiveWorkbook.Name
If tempName <> "!PAGE ONE_InvTemplate.xls" Then
Sheets("Simple Invoice").Protect, userinterfaceonly:=True
Exit Sub
End If

Unfortunately, this doesn't work either. Or, did I misunderstand what you meant? Any other ideas?