Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Protect Selected Sheets

I am trying to write some code to protect all of the selected sheets. I
kept getting an application error in the code below until I added the
objSheet.Select line prior to the .Protect line. Why does it not work
unless I select the sheet first?

bAllOK = True
For Each objSheet In ActiveWindow.SelectedSheets
If Not bSheetIsProtected(objSheet) Then
objSheet.Select
objSheet.Protect Password:=strPW, Contents:=True
Else
strLocked = strLocked & Chr(10) & objSheet.Name
bAllOK = False
End If
Next objSheet


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Protect Selected Sheets

Nevermind...I think I figured it out. You cannot protect sheets when
multiple sheets are selected (based on the fact that Tools | Protection |
Protect Sheets is greyed out if more than one sheet is selected). The
..Select statement therefore works by ensuring only one sheet is selected.


"M. Authement" wrote in message
...
I am trying to write some code to protect all of the selected sheets. I
kept getting an application error in the code below until I added the
objSheet.Select line prior to the .Protect line. Why does it not work
unless I select the sheet first?

bAllOK = True
For Each objSheet In ActiveWindow.SelectedSheets
If Not bSheetIsProtected(objSheet) Then
objSheet.Select
objSheet.Protect Password:=strPW, Contents:=True
Else
strLocked = strLocked & Chr(10) & objSheet.Name
bAllOK = False
End If
Next objSheet



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
Protect selected settings in 'options' John Excel Worksheet Functions 4 June 15th 09 07:48 AM
Protect selected column Fareez Excel Discussion (Misc queries) 1 February 20th 09 06:50 AM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Programming 6 March 29th 06 12:43 PM
Protect selected sheet(s) Kevin McCartney Excel Programming 1 March 17th 06 04:58 PM


All times are GMT +1. The time now is 08:50 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"