Protecting Workbook!..

  • Thread starter Thread starter Neo1
  • Start date Start date
N

Neo1

Hello, I want to make sure that my workbook doesnt close until ever
single sheet is protected if any worksheet is left unprotected then th
user must protect it before being able to close the workbook, How can
do this...possibly showing an error message too...

Thanks a lot
From Joh
 
If you name a macro beforeClose() this run before the workbook closes.
You can then put the code in here to make the sheets protected.

Thanks
Paul
 
I dont understand, can you explain it to me step to step please

Thanks a lot
From John
 
John
Put the code below in the Thisworkbook not in a normal module in the VBA
editor.
If you want I can email you the file
Thanks
Paul

Private Sub Workbook_BeforeClose(Cancel As Boolean)
sh = Worksheets.Count

For n = 1 To sh
Sheets(n).Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Next n

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top