none
No context provided for a Ribbon button in Protected View in PowerPoint and Word RRS feed

  • Question

  • Hello,

    Create a PowerPoint or Word 2013-2016 add-in showing a Ribbon button. Use the following code in the Click event of that button:

        Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) Handles Button1.Click
            Dim context As Object = e.Control.Context
            Dim result As String = "(not set)"
            If context Is Nothing Then
                result = "context Is Nothing"
            Else
                result = "context type name is " + Microsoft.VisualBasic.Information.TypeName(context)
            End If
            System.Windows.Forms.MessageBox.Show(result)
        End Sub
    Open a presentation/document and click the button. The resulting message shows that the type name of the context object is "DocumentWindow" ("Window" in case of Word); this is expected. Open a presentation/document in Protected View and click the button. The message is "context is Nothing". This isn't expected; I expect to get a ProtectedViewWindow object - this is what Excel returns in this scenario.

    If extra info is required, please let me know.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Wednesday, August 10, 2016 12:55 PM

All replies

  • Hi Andrei Smolin,

    does it happen when you have by default protected view on in Word Options.

    or only when you open the file using Protected view.

    I had test with by default setting and I get "context type name is window"

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 11, 2016 5:39 AM
    Moderator
  • Hello Deepak,

    Thank you for looking into this issue.

    When reproducing the issue I opened an existing document using the FileOpen dialog. You open that dialog via File | Open | Browse. Then you need to select a file, click the arrow on the Open button and select Open in Protected View from the list.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Thursday, August 11, 2016 9:02 AM
  • Hi Andrei Smolin,

    I try to test it and I find that I got the same output like you.

    so you can submit your feedback to Word User Voice regarding this issue.

    please visit the link below to give feedback.

    Word User Voice

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, August 18, 2016 4:25 AM
    Moderator