How to programmatically check if a workbook is protected t?

  • Thread starter Thread starter uno@korsmaa
  • Start date Start date
U

uno@korsmaa

Hello

How to programmatically check if a workbook is protected or not?

Rgs
Uno Kõrsmaa
 
For a workbook

With Workbook
if .ProtectWindows or
.ProtectStructure then

End if
End With


For a Worksheet

With ActiveSheet
if .ProtectContents = True or _
.ProtectDrawingObjects = True or _
.ProtectScenarios = True or _
.ProtectMode = True then

' sheet is protected
End if
End With



If you want to know if a workbook is password protected, I believe you have
to attempt to open it and see if the attempt fails (suppressing the prompt
and handling the error)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top