1 Attachment(s)
Detecting "Protected View"
Is there a way to detect if a Workbook has been opened in "Protected View?"
I've built a tool that allows someone to edit various templates downloaded from my companies intranet. Sometimes these templates open "Protected View" due to the security/trust settings of varying computers.
If I could figure out how to detect if a workbook has been opened in this state, I could then tell the user to click the yellow button to make it editable.
But I'm having trouble with this. Excel doesn't seem to even acknowledge the existence of a workbook in "Protected View."
The Image Below:
Book1 (just a blank workbook I'm testing code in)
027_001 US_GT... (One of the workbooks that has been opened in "Protected View"
VBA Project Window (Book1 is the only shown workbook. 027_001... doesn't even appear!)
Any insight would be GREATLY appreciated.
Attachment 11109
Detecting "Protected View"
The ProtectedViewWindows Object was added in 2010, so to support earlier versions you will have to indirectly invoke the object.
Something like :
Code:
Public Property Get IsProtectedView() As Boolean
Dim Pvw As Object
On Error GoTo err_handler
Set Pvw = CallByName(Application, "ProtectedViewWindows", VbGet)
If Not Pvw Is Nothing Then
IsProtectedView = Pvw.Count > 0
End If
err_handler:
Set Pvw = Nothing
End Property