Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default How to detect protected sheet

How do I detect whther a sheet is protected or not? I need the sheet
unprotected for the subroutine, but I need to know whether it was already
unprotected so I can leave it in the same satte after the sub runs.

--
Ian
--


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How to detect protected sheet

Do it the type of item being protected:

Sub dural()
Dim s As Worksheet
Dim t As Boolean
Set s = ActiveSheet
t = s.ProtectContents
MsgBox (t)
End Sub

--
Gary''s Student - gsnu200905


"IanC" wrote:

How do I detect whther a sheet is protected or not? I need the sheet
unprotected for the subroutine, but I need to know whether it was already
unprotected so I can leave it in the same satte after the sub runs.

--
Ian
--



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default How to detect protected sheet

Directly from VBA help on ProtectContents Property

If Worksheets("Sheet1").ProtectContents = True Then
MsgBox "The contents of Sheet1 are protected."
End If


Gord Dibben MS Excel MVP

On Tue, 29 Sep 2009 17:15:31 +0100, "IanC" wrote:

How do I detect whther a sheet is protected or not? I need the sheet
unprotected for the subroutine, but I need to know whether it was already
unprotected so I can leave it in the same satte after the sub runs.

--
Ian


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default How to detect protected sheet

Thanks. I'd tried the ProtectionMode property and couldn't get it to work.
Your solution is just what I needed.

--
Ian
--

"Gary''s Student" wrote in message
...
Do it the type of item being protected:

Sub dural()
Dim s As Worksheet
Dim t As Boolean
Set s = ActiveSheet
t = s.ProtectContents
MsgBox (t)
End Sub

--
Gary''s Student - gsnu200905


"IanC" wrote:

How do I detect whther a sheet is protected or not? I need the sheet
unprotected for the subroutine, but I need to know whether it was already
unprotected so I can leave it in the same satte after the sub runs.

--
Ian
--





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default How to detect protected sheet


"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Directly from VBA help on ProtectContents Property

If Worksheets("Sheet1").ProtectContents = True Then
MsgBox "The contents of Sheet1 are protected."
End If


Thanks Gord. I looked at this after Gary's Student pointed me this way. It's
easy when you know what keywords to look for. I'd searched for "Protect" and
ProtectionMode sounded the most likely....

.....but wasn't

--
Ian
--


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
Detect existence of a sheet Cleber Inacio Excel Programming 5 November 19th 07 09:33 PM
detect and delete existing sheet swiftcode Excel Discussion (Misc queries) 3 September 16th 05 05:20 PM
How to detect if sheet is hidden? hstijnen Excel Worksheet Functions 1 March 24th 05 02:40 PM
Detect Password Protection on a Sheet Chris Gorha Excel Programming 2 January 10th 04 09:17 AM
Function to detect if Sheet is protected Niklas[_4_] Excel Programming 1 October 7th 03 09:11 AM


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