Thanks,
Rachmat Hartono
There really isn't any direct way to determine if the file is protected,
you just have to try to open it and then check to see it you succeeded.
Here's an example:
Sub OpenFile()
Dim wkbBook As Workbook
Application.DisplayAlerts = False
On Error Resume Next
''' First line only required when doing this in a loop.
Set wkbBook = Nothing
Set wkbBook = Workbooks.Open("C:\MyBook.xls")
On Error GoTo 0
If wkbBook Is Nothing Then
MsgBox "Workbook was password protected."
Else
MsgBox "Workbook opened"
End If
Application.DisplayAlerts = True
End Sub
Note: other reasons besides password protection, the workbook not existing
at all, for instance, will cause this procedure to act as if the workbook
specified was password protected, so you have to take those things into
account before applying this method.
--
Rob Bovey, MCSE, MCSD
The Payne Consulting Group
http://www.payneconsulting.com
Rachmat Hartono wrote in message <#dPhqiFB$GA.261@cppssbbsa05>...
Venkata Krishna <krish...@hotmail.com> wrote in message news:eqzp2fHB$GA....@cppssbbsa02.microsoft.com...
Best regards,
Rachmat Hartono
Venkata Krishna <krish...@hotmail.com> wrote in message
news:eAyC9oJB$GA.226@cppssbbsa03...