#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default ProtectScan

Wy get a and error
Error 424 - Object requires - on "Workbook.Sheets(Sheet1).Select"

Sub ProtectScan()
Sheet1 = ActiveSheet.Name
MyNote = ""
For Each Sht In ActiveWorkbook.Sheets
Sht.Select
IsProtected = Application.ExecuteExcel4Macro("get.document(7)")
MyNote = MyNote & Sht.Name & ": " & IsProtected & vbCrLf
Next Sht
Workbook.Sheets(Sheet1).Select
MsgBox Prompt:=MyNote, Title:="Sheet Protection On"
End Sub

JP

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default ProtectScan

Unless you did something with the codenames of the worksheets, I bet you're
confusing excel.

Try changing Sheet1 to mySheet1 in both spots.

And you don't need to use that old xlm macro line:

isprotected = sht.ProtectContents _
Or sht.ProtectDrawingObjects _
Or sht.ProtectScenarios

And there shouldn't be a reason to use "Sht.Select" either.

Maybe:

Option Explicit
Sub ProtectScan()
Dim Sht as object 'worksheet, chartsheet, macrosheet, ...
Dim myNote as string
Dim IsProtected as boolean

myNote = ""
For Each Sht In ActiveWorkbook.Sheets
isprotected = sht.ProtectContents _
Or sht.ProtectDrawingObjects _
Or sht.ProtectScenarios
MyNote = MyNote & Sht.Name & ": " & IsProtected & vbLf
Next Sht
MsgBox Prompt:=MyNote, Title:="Sheet Protection On"
End Sub



Pierre wrote:

Wy get a and error
Error 424 - Object requires - on "Workbook.Sheets(Sheet1).Select"

Sub ProtectScan()
Sheet1 = ActiveSheet.Name
MyNote = ""
For Each Sht In ActiveWorkbook.Sheets
Sht.Select
IsProtected = Application.ExecuteExcel4Macro("get.document(7)")
MyNote = MyNote & Sht.Name & ": " & IsProtected & vbCrLf
Next Sht
Workbook.Sheets(Sheet1).Select
MsgBox Prompt:=MyNote, Title:="Sheet Protection On"
End Sub

JP


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default ProtectScan


Dave Peterson,

It works, many thanks.

JP

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



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