How to have workbook automatically protect when closed (or opened)

D

DrewParkinson

Hi,

I have a spreadsheet (MS Excel 2003) that is currently shared over a
network among many users. Currently, we have some columns protected
from editing. However, some of the user base who edit the sheet and
have the password tend to not protect the workbook again after they
are doing edits (managers).

Anyone know of a macro or other method that would have the workbook
automatically be protected, even if it was saved unprotected? Possibly
protected on close/open, or on save?

Thanks,
Drew
 
G

Guest

Paste this into the ThisWorkbook Module

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Replace "Password" with your password that you use
'this will set password when closing workbook
ActiveSheet.Protect "Password", True
ActiveWorkbook.Protect "Password", True

End Sub
 
D

DrewParkinson

Paste this into the ThisWorkbook Module

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Replace "Password" with your password that you use
'this will set password when closing workbook
ActiveSheet.Protect "Password", True
ActiveWorkbook.Protect "Password", True

End Sub

Wow, awesome thanks for the quick response, works perfectly~
 

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

Top