using pword and auto protect

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is what i currently use to auto protect sheet, but i want to add a
password to this, (2468) so that the protection is password protected, but i
do not know how
the current syntax can be adjusted to perform this request?
I tried to put a password on the regular way of protect and then entering a
pword, however when the workbook opens up it goes into a debug error and I
have to have this sheet protected automatically because without it set up
that way one of my macros doesnt work.

Option Explicit

Private Sub Workbook_Open()
ThisWorkbook.Sheets("Patrol Log") _
.Protect DrawingObjects:=True, _
contents:=True, Scenarios:=True, _
UserInterfaceOnly:=True
End Sub
 
Brian, try this,

Option Explicit

Private Sub Workbook_Open()
ThisWorkbook.Sheets("Patrol Log") _
.Protect Password:="2468", DrawingObjects:=True, _
contents:=True, Scenarios:=True, _
UserInterfaceOnly:=True
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 
Private Sub Workbook_Open()
ThisWorkbook.Sheets("Patrol Log") _
.Protect Password:="2468", _
DrawingObjects:=True, _
contents:=True, _
Scenarios:=True, _
UserInterfaceOnly:=True
End Sub

I didn't test it to see it 2468 should be entered with or without quotes.
You can play with that.
 
Perfect!!
Thank You


Paul B said:
Brian, try this,

Option Explicit

Private Sub Workbook_Open()
ThisWorkbook.Sheets("Patrol Log") _
.Protect Password:="2468", DrawingObjects:=True, _
contents:=True, Scenarios:=True, _
UserInterfaceOnly:=True
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 
Works,
How can I add three more sheets to this syntax "report" "log" and "list"?
 
Private Sub Workbook_Open()
Dim sh as Worksheet, varr as Variant
set sh = ThisWorkbook.Activesheet
varr = Array("Patrol Log", "report", "log", "list")
for i = lbound(varr) to ubound(varr)
With ThisWorkbook.Sheets(varr(i)) _
.Activate
.Protect Password:="2468", _
DrawingObjects:=True, _
contents:=True, _
Scenarios:=True, _
UserInterfaceOnly:=True
End With
Next
sh.Activate
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