Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default using pword and auto protect

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default using pword and auto protect

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

"Brian" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default using pword and auto protect

Perfect!!
Thank You


"Paul B" wrote:

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

"Brian" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default using pword and auto protect

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.


--
Regards,
Tom Ogilvy

"Brian" wrote in message
...
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default using pword and auto protect


Works,
How can I add three more sheets to this syntax "report" "log" and "list"?



"Tom Ogilvy" wrote:

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.


--
Regards,
Tom Ogilvy

"Brian" wrote in message
...
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






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default using pword and auto protect

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

--
Regards,
Tom Ogilvy


"Brian" wrote in message
...

Works,
How can I add three more sheets to this syntax "report" "log" and "list"?



"Tom Ogilvy" wrote:

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.


--
Regards,
Tom Ogilvy

"Brian" wrote in message
...
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set auto protect workbook on exit? West Excel Worksheet Functions 4 October 2nd 06 03:19 AM
How do I auto-protect a worksheet? West Excel Worksheet Functions 1 March 31st 05 03:39 AM
can I send authentication data i.e. username & pword from an exce. moffett Excel Programming 1 September 21st 04 12:45 AM
auto protect or run VBA? Michel[_3_] Excel Programming 2 September 15th 03 08:50 PM
Macro to protect with pword in 97 Wes[_4_] Excel Programming 1 September 15th 03 05:34 PM


All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"