View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Marc[_20_] Marc[_20_] is offline
external usenet poster
 
Posts: 7
Default Before Close workbook?

I have protected sheet and workbook with password.
I have this code and is working ok. Does anyone have some suggestions to
this code, as I am beginner?

Private Sub Workbook_BeforeClose(cancel As Boolean)
Dim L As Long
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect (5)
Me.Worksheets(1).Visible = True
For L = 2 To Me.Worksheets.Count
Me.Worksheets(L).Visible = xlVeryHidden
Next

ActiveWorkbook.Protect Password:="5", Structu=True, Windows:=False
ActiveWorkbook.Save
End Sub

similar is for Open