Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default auto-protect a sheet upon workbook close

Hi, I am trying to auto-protect a sheet upon workbook close (so people a
certain person doesnt forget to reapply protection when closing out of a
file that he maintains).
The below macro works fine, but disables ALL options for the user.
Sub ApplySecurity()
Worksheets("Master").Protect Password:="1225"
End Sub

Id like to allow the user to a few basic things, such as select
locked/unlocked cells, use auto filter, and edit objects.

Sub ApplySecurity()
Worksheets("Master").Protect DrawingObjects:=False, Contents:=True,
Scenarios:= _
True, AllowFiltering:=True Worksheets("Master").Protect

End Sub

How do I add the password in there? Ive tried a couple things; I get only
errors.

In ThisWorkbook, Ive got:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call ApplySecurity
End Sub

Private Sub Workbook_Open()
Call ApplySecurity
End Sub

Thanks,
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default auto-protect a sheet upon workbook close

Hi,

Like this

Sub ApplySecurity()
Worksheets("Master").Protect Password:="1234", DrawingObjects:=False, _
Contents:=True, Scenarios:=True, AllowFiltering:=True

End Sub

"ryguy7272" wrote:

Hi, I am trying to auto-protect a sheet upon workbook close (so people a
certain person doesnt forget to reapply protection when closing out of a
file that he maintains).
The below macro works fine, but disables ALL options for the user.
Sub ApplySecurity()
Worksheets("Master").Protect Password:="1225"
End Sub

Id like to allow the user to a few basic things, such as select
locked/unlocked cells, use auto filter, and edit objects.

Sub ApplySecurity()
Worksheets("Master").Protect DrawingObjects:=False, Contents:=True,
Scenarios:= _
True, AllowFiltering:=True Worksheets("Master").Protect

End Sub

How do I add the password in there? Ive tried a couple things; I get only
errors.

In ThisWorkbook, Ive got:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call ApplySecurity
End Sub

Private Sub Workbook_Open()
Call ApplySecurity
End Sub

Thanks,
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default auto-protect a sheet upon workbook close

Hi,

I should have added that your calls to this sub will work fine

Mike

"Mike H" wrote:

Hi,

Like this

Sub ApplySecurity()
Worksheets("Master").Protect Password:="1234", DrawingObjects:=False, _
Contents:=True, Scenarios:=True, AllowFiltering:=True

End Sub

"ryguy7272" wrote:

Hi, I am trying to auto-protect a sheet upon workbook close (so people a
certain person doesnt forget to reapply protection when closing out of a
file that he maintains).
The below macro works fine, but disables ALL options for the user.
Sub ApplySecurity()
Worksheets("Master").Protect Password:="1225"
End Sub

Id like to allow the user to a few basic things, such as select
locked/unlocked cells, use auto filter, and edit objects.

Sub ApplySecurity()
Worksheets("Master").Protect DrawingObjects:=False, Contents:=True,
Scenarios:= _
True, AllowFiltering:=True Worksheets("Master").Protect

End Sub

How do I add the password in there? Ive tried a couple things; I get only
errors.

In ThisWorkbook, Ive got:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call ApplySecurity
End Sub

Private Sub Workbook_Open()
Call ApplySecurity
End Sub

Thanks,
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default auto-protect a sheet upon workbook close

So weird; thought I tried that. I probably forgot the comma after the
password. Thanks MikeH!!!
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Mike H" wrote:

Hi,

Like this

Sub ApplySecurity()
Worksheets("Master").Protect Password:="1234", DrawingObjects:=False, _
Contents:=True, Scenarios:=True, AllowFiltering:=True

End Sub

"ryguy7272" wrote:

Hi, I am trying to auto-protect a sheet upon workbook close (so people a
certain person doesnt forget to reapply protection when closing out of a
file that he maintains).
The below macro works fine, but disables ALL options for the user.
Sub ApplySecurity()
Worksheets("Master").Protect Password:="1225"
End Sub

Id like to allow the user to a few basic things, such as select
locked/unlocked cells, use auto filter, and edit objects.

Sub ApplySecurity()
Worksheets("Master").Protect DrawingObjects:=False, Contents:=True,
Scenarios:= _
True, AllowFiltering:=True Worksheets("Master").Protect

End Sub

How do I add the password in there? Ive tried a couple things; I get only
errors.

In ThisWorkbook, Ive got:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call ApplySecurity
End Sub

Private Sub Workbook_Open()
Call ApplySecurity
End Sub

Thanks,
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default auto-protect a sheet upon workbook close

Your welcome and thanks for the feedback

"ryguy7272" wrote:

So weird; thought I tried that. I probably forgot the comma after the
password. Thanks MikeH!!!
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Mike H" wrote:

Hi,

Like this

Sub ApplySecurity()
Worksheets("Master").Protect Password:="1234", DrawingObjects:=False, _
Contents:=True, Scenarios:=True, AllowFiltering:=True

End Sub

"ryguy7272" wrote:

Hi, I am trying to auto-protect a sheet upon workbook close (so people a
certain person doesnt forget to reapply protection when closing out of a
file that he maintains).
The below macro works fine, but disables ALL options for the user.
Sub ApplySecurity()
Worksheets("Master").Protect Password:="1225"
End Sub

Id like to allow the user to a few basic things, such as select
locked/unlocked cells, use auto filter, and edit objects.

Sub ApplySecurity()
Worksheets("Master").Protect DrawingObjects:=False, Contents:=True,
Scenarios:= _
True, AllowFiltering:=True Worksheets("Master").Protect

End Sub

How do I add the password in there? Ive tried a couple things; I get only
errors.

In ThisWorkbook, Ive got:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call ApplySecurity
End Sub

Private Sub Workbook_Open()
Call ApplySecurity
End Sub

Thanks,
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.

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
auto close workbook [email protected] uk Excel Discussion (Misc queries) 2 December 6th 09 09:02 PM
Auto-Protect Sheet on Open and on Close ryguy7272 Excel Programming 3 October 6th 09 07:00 PM
how to setup a excel sheet to be protect after save and close file Marco Excel Discussion (Misc queries) 0 March 11th 08 10:56 PM
Auto Excel workbook close: save= false during an auto subroutine tomwashere2 Excel Programming 10 June 16th 05 06:23 AM
Auto Close A Workbook...With Two Twists! jwleonard[_4_] Excel Programming 0 September 18th 04 08:48 AM


All times are GMT +1. The time now is 06:02 PM.

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

About Us

"It's about Microsoft Excel"