View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
marcus[_3_] marcus[_3_] is offline
external usenet poster
 
Posts: 140
Default Run a code on a workbook?

hey Lostguy

This will do the first part of your question, so you can put this in a
seperate workbook and it will open your original workbook and say
which sheets are protected. Just change the file name and path.

I will have a look into the workbook protection for you.

Take care

Marcus


Sub testopen()
Dim ws As Worksheet
Dim result As String
FName = "C:\open.xls"

Set oldbk = Workbooks.Open(Filename:=FName)
result = ""
For Each ws In Worksheets
result = result & ws.Name & " is " _
& IIf(ws.ProtectContents, "protected", "unprotected") & vbCr
Next ws
MsgBox result
oldbk.Close savechanges:=False

End With

End Sub