Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Protect Selected Sheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
M. Authement - 07 Dec 2007 00:12 GMT
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
M. Authement - 07 Dec 2007 00:31 GMT
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.

>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
[quoted text clipped - 11 lines]
>     End If
> Next objSheet
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.