Document in protected window? RRS feed

  • Question

  • Hi;

    How do I determine if a document is in a protected window or in the protected mode? By protected I mean the new Word 2010 mode for files downloaded from the internet.

    thanks - dave

    Very funny video - What's your Metaphor?
    Wednesday, March 9, 2011 6:03 PM


All replies

  • Hi David,

    Thank you for posting.

    As far as I know, I am afraid we can't programmatically jugding whether the word 2010 document is in a protected window.

    However, we can judge whether it is in the protected window while opening the word doucment from UI. Please take a look at this article: which introduce the detail information about protect view.

    I hope this can help you.

    Best Regards,

    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 10, 2011 6:18 AM
  • This isn't a solution, but an observation that may lead to one:

    In the object model, there are two separate collections, Windows and ProtectedViewWindows. Any particular window is a member of one or the other but not both.

    For example, if you open two "local" (not protected) documents and one protected document, then Windows.Count = 2 and ProtectedViewWindows.Count = 1.

    Now, what's interesting is that if the protected window is active (has the focus) and you try to access ActiveWindow.Caption or some other property of ActiveWindow, you'll get error 4248, "This
    command is not available because no document is open".

    So my suggestion is to open the document in question and use an error trap like this:

        Dim s As String
        On Error Resume Next
        s = ActiveWindow.Caption
        If Err.Number = 4248 Then
            MsgBox ActiveProtectedViewWindow.Document.FullName & " is protected."
            Exit Sub
        End If

        ' work on unprotected document

    Jay Freedman
    MS Word MVP  FAQ:
    Thursday, March 10, 2011 2:27 PM
  • Hi Jay;

    We're doing something similiar to that. The problem we're hitting is when we get the open_document event after enabling the document - that test still shows it as protected.

    thanks - dave

    Very funny video - What's your Metaphor?
    Thursday, March 10, 2011 4:37 PM
  • Bruce;

    Please push this question up to the Word development team. What we can do on a protected document is limited and therefore in our AddIn we need to know if a document is protected. They must have a way to tell us if the document is protected because of these limitations.

    And we need a way to determine this even if the document is not presently active.

    thanks - dave

    Very funny video - What's your Metaphor?
    Thursday, March 10, 2011 4:39 PM
  • Best solution we've found, walk the list of protected windows and check the Document property of each.
    Very funny video - What's your Metaphor?
    • Marked as answer by DavidThi808 Tuesday, March 15, 2011 10:12 PM
    Tuesday, March 15, 2011 10:12 PM