Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Worksheet Protection

I have a template worksheet that I am trying to use a macro to set passwords
to protect:
1) the workbook level to allow only employee access
2) the worksheet level to protect formulas from being overwritten and limit
access to myself

The attached macro saves the template as a separate filename and tries to
accomplish the objectives listed above. But when I go into the saved
worksheet, only the workbook is protected. The worksheet isn't. What am I
doing wrong?

Sheets("Selections1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="PASSWORD1"
Sheets("Selections2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="PASSWORD1"
myFileName = Sheet8.Range("D2").Value & Sheet8.Range("B2").Value
ActiveWorkbook.SaveAs Filename:="V:\Selections\Jobs\" & myFileName &
".xls", _
FileFormat:=xlNormal, Password:="PASSWORD2", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=True


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Worksheet Protection

It *looks* like it should work.... but maybe you're protecting sheets on
a different workbook from the workbook you are protecting. Try and be
more explicit in your code. I've modified your code slightly, by using
the With statement and the "." we can be certain that we're working on
the same workbook.

With Activeworkbook

.Sheets("Selections1").Protect DrawingObjects:=True, _

Contents:=True, _
Scenarios:=True, _
Password:="PASSWORD1"
.Sheets("Selections2").Protect DrawingObjects:=True, _

Contents:=True, _
Scenarios:=True, _
Password:="PASSWORD1"

myFileName = .Sheet8.Range("D2").Value & .Sheet8.Range("B2").Value
.SaveAs Filename:="V:\Selections\Jobs\" & myFileName & ".xls", _
FileFormat:=xlNormal, _
Password:="PASSWORD2", _
WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=True

End with

HTH,
Gareth

r wilcox wrote:
I have a template worksheet that I am trying to use a macro to set passwords
to protect:
1) the workbook level to allow only employee access
2) the worksheet level to protect formulas from being overwritten and limit
access to myself

The attached macro saves the template as a separate filename and tries to
accomplish the objectives listed above. But when I go into the saved
worksheet, only the workbook is protected. The worksheet isn't. What am I
doing wrong?

Sheets("Selections1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="PASSWORD1"
Sheets("Selections2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="PASSWORD1"
myFileName = Sheet8.Range("D2").Value & Sheet8.Range("B2").Value
ActiveWorkbook.SaveAs Filename:="V:\Selections\Jobs\" & myFileName &
".xls", _
FileFormat:=xlNormal, Password:="PASSWORD2", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=True


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
Worksheet Protection Susan Excel Worksheet Functions 3 January 19th 08 01:10 AM
Cell Protection vs. Worksheet Protection kmwhitt Excel Discussion (Misc queries) 4 September 24th 06 02:37 AM
Worksheet protection is gone and only wokbook protection can be se Eric C. Excel Discussion (Misc queries) 4 May 2nd 06 04:50 PM
Worksheet Protection stwky Excel Discussion (Misc queries) 3 April 12th 05 10:21 AM
worksheet protection losmac Excel Programming 0 August 20th 03 10:01 PM


All times are GMT +1. The time now is 05:56 PM.

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"