View Single Post
  #3   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?

Ooops

I left an errant line in the code. Sorry about that.

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 Sub