password protecting sheet when workbook opens

M

mercer77

I want a sheet in my workbook to be automatically protected when i
opens. So, I put this into 'ThisWorkbook':

Private Sub Workbook_Open()
Password = "jack"
ThisWorkbook.Sheets("invoice list").Protect Password:=Password
End Sub

Then I closed the workbook, reopened it, and the sheet was protected
However, I am now unable to unprotect it, as I keep getting told tha
I've got the wrong password!

Firstly, does anyone know how I can unprotect this? Secondly, what di
I do wrong? how can I get this to work?

Thanks!
 
M

mercer77

Problem solved!

This seems to work, basically specifying the workbook. I don'
understand the difference - I guess it's just one of those littl
mysteries.... :)

Private Sub Workbook_Open()
Dim Password
Password = "jack"
Workbooks("INVOICESv2a.XLS").Sheets("invoice list").Protec
Password:=Password
End Su
 

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