Detect Password Protection

O

Otto Moehrbach

Keith
Something like this perhaps:
Sub testme02()
Dim wks As Worksheet
Set wks = ActiveSheet
With wks
If .ProtectContents _
Or .ProtectDrawingObjects _
Or .ProtectScenarios Then
MsgBox "oh, oh. Somekind of protection"
End If
End With
End Sub

HTH Otto
 
K

Keith Ralston

Can this be done before I attempt to open the spreadsheet?

I need to process a large number of XLS files. I want to note pwd
protected files as exceptions. I am using Automation, not VBA as you
have indicated below.
 
D

Dave Peterson

Otto's code checks for worksheet protection. It kind of sounds like you want to
check for the file|open type of protection.

I'm not sure how you're automating this (VB??), but if I were doing it in
excel's VBA, I could do try to open it with a password of "" and if it failed,
it had a real password:

Here's a link that uses Excel to make a report for each workbook in a folder:
http://groups.google.com/[email protected]
 
Top