View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
onedaywhen onedaywhen is offline
external usenet poster
 
Posts: 459
Default Interesting challenge

Also use the workbook_close event of your workbook to
- hide the sheets again
- unhide the welcome sheet
- save the workbook with these settings


This would allow the crafty user (takes one to know one) to open the
workbook with macros enabled (to allow the protection code to run),
save but don't close it and crash Excel to ensure the Workbook_Close
event (i.e. protection code) does not run. Result is, if they then
open the workbook a second time with macros disabled, they will have
an unprotected workbook. Tant va la cruche à l'eau qu'à la fin elle se
brise.

Better to do the above process in the Workbook_BeforeSave event,
remembering to handle the case where the event fires but the user
cancels the save. Force a ThisWorkbook.Save in Workbook_Close. Also
handle the case where the workbook is saved but not closed i.e. run
the Workbook_Open code again. La fin justifie les moyens.

--