Spikenaylor
Board Regular
- Joined
- Apr 14, 2013
- Messages
- 116
- Office Version
- 365
- Platform
- Windows
We are trying to Debug/verify code as part of our validation process
simple spreadsheet
code to auto lock on open and auto lock and save on close
We can run through the debugging (F8) for the Workbook_Open
but cannot get the dubugging to run for the Workbook_BeforeClose
any idea why?
Regards
Thanks for looking
simple spreadsheet
code to auto lock on open and auto lock and save on close
Code:
Option Explicit
Private Sub Workbook_Open()
Dim i As Long
ThisWorkbook.Unprotect SheetPasswrd
Application.WindowState = xlMaximized
ThisWorkbook.Protect SheetPasswrd
For i = 1 To Sheets.Count
Sheets(i).Protect SheetPasswrd
Next i
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
Dim i As Long
For i = 1 To Sheets.Count
Sheets(i).Protect SheetPasswrd
Next i
ThisWorkbook.Protect SheetPasswrd
Application.ScreenUpdating = True
ActiveWorkbook.Close Savechanges:=True
End Sub
We can run through the debugging (F8) for the Workbook_Open
but cannot get the dubugging to run for the Workbook_BeforeClose
any idea why?
Regards
Thanks for looking