I am using the AutoOpen event to unprotect my workbooks and worksheets on open, but cannot seem to get the opposite to happen in the beforeclose event. Actually, I've not gotten anything to work with the BeforeClose() Event in my first attempts. How would I go about using the BeforeClose() Event, and actually getting it to work. Any examples, instructions, websites, tutorials, etc. welcome. I would like any information anyone has on this event. The BeforeSave event and/or the BeforeClose event would be great. Also, if someone could tell me how all the events trigger in Excel like in Access. (I have 3 Access books, but no Excel books to date for reference. My books are from Sybex, and have been most helpful).
Thanks for any information in this area.
BTW, here is my code linked to a button for protecting the sheets/workbook:
I basically copied and pasted the code from the msdn website, then edited it to my liking. Here is the link where I found it, in case anyone needs some information in protecting workbooks/sheets (this is not "hacker proof", but it does good enough for my purposes.
Stephen![[infinity] [infinity] [infinity]](/data/assets/smilies/infinity.gif)
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
Thanks for any information in this area.
BTW, here is my code linked to a button for protecting the sheets/workbook:
Code:
Sub ProtectMyWorkBook()
'
' ProtectMyWorkBook Macro
' Macro recorded 5/4/2004 by sferguson
'
Dim shtCurrent As Worksheet
ActiveWorkbook.Protect "admin", Structure:=True, Windows:=False
' Loop through each worksheet in the active workbook
For Each shtCurrent In ActiveWorkbook.Worksheets
' Protect the worksheet. Allow the users to format
' and sort cells.
shtCurrent.Protect Password:="admin", _
Contents:=True, _
DrawingObjects:=True, _
Scenarios:=True, _
AllowFormattingCells:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowSorting:=True, _
AllowFiltering:=True
Next
End Sub
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexcl2k2/html/odc_xlwebProtSht.asp
Stephen
![[infinity] [infinity] [infinity]](/data/assets/smilies/infinity.gif)
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV