Quantcast
Channel: General Office Development forum
Viewing all articles
Browse latest Browse all 2257

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

$
0
0

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.


Viewing all articles
Browse latest Browse all 2257

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>