none
A Ribbon XML that crashes Powerpoint 2010 RRS feed

  • Question

  • Hi

    I have an issue with an Xml Ribbon and PowerPoint 2010.

    It seems important given the simplicity of the steps required to reproduce it (bug obtained on various blank test machines with PowerPoint 2010 and various configurations of OS).

    To reproduce, create a new PowerPoint 2010 AddIn Project (in my case with VS 2010), then add a XML Ribbon, and the following
    code :

    In the Ribbon

        Public Sub RibbonLoad(ByVal ribbonUI As Office.IRibbonUI)

            Ribbon = ribbonUI

        End Sub

        Private Ribbon As Office.IRibbonUI

        Public Sub Refresh()
            Ribbon.InvalidateControl("MyTab")
        End Sub

        Function GetLabel(control As IRibbonControl)

            Return "TestTab"

        End Function

    In thisAddin.vb

        Public Class ThisAddIn

        Public myRibbonHost As PptRibbon

        Protected Overrides Function CreateRibbonExtensibilityObject() As Microsoft.Office.Core.IRibbonExtensibility

        myRibbonHost = New PptRibbon()

            Return myRibbonHost

        End Function

        Private Sub ThisAddInStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup

            AddHandler Application.PresentationClose, AddressOf myRibbonHost.Refresh

        End Sub

    End Class

    In content into Ribbon.XMl

    <?xml version="1.0" encoding="UTF-8"?>
       
    <customUI onLoad="RibbonLoad" xmlns="http://schemas.microsoft.com/office/2006/01/customui" >
            <
    ribbon>
                <
    tabs>
                            <tab id="MyTab" getLabel="GetLabel" insertBeforeMso="TabHome"/>
                </tabs>
            </
    ribbon>
        </
    customUI>

    Now to reproduce the bug, create a new presentation, go to master view, and close PowerPoint.

    The application crashes.

    Why was I confronted to this issue?

    I use the windowActivate event to refresh the enable state of my buttons (for example i have buttons whish should only be enabled when shapes are selected). This code is the result of my trying to reproduce the issue with minimum code.

    Additional informations

    - This does not happen in PowerPoint 2007

    - I can reproduce the issue with anyApplication.Window* events or with theapplication.presentationClose event, even if the events are not fired when users closes PowerPoint

    - It is enough for the event to be fired once. PowerPoint will crash if you close it in any master view (slide, handout, or notes)

    - If you remove the insertBeforeMso tag from the Xml, the bug disappears, except if you use the application.presentationClose event

    Any ideas, to avoid this issue?

    Thanks in advance,

    Nicolas.






    • Edited by Avlin67 Wednesday, May 16, 2012 9:28 AM
    Thursday, May 10, 2012 12:19 PM

Answers

  • Sorry to bring up this old thread, but we also had this problem.

    In short: We solved this issue by evading calls to Ribbon.Invalidate() if ppt is in Master view.

    if (_ribbon != null && !IsMasterActive())
           _ribbon.Invalidate();
    
    private bool IsMasterActive()
            {
                try{
                    return Globals.ThisAddIn.Application.ActiveWindow.ActivePane.ViewType == PpViewType.ppViewSlideMaster ||
                        Globals.ThisAddIn.Application.ActiveWindow.ActivePane.ViewType == PpViewType.ppViewTitleMaster ||
                        Globals.ThisAddIn.Application.ActiveWindow.ActivePane.ViewType == PpViewType.ppViewNotesMaster ||
                        Globals.ThisAddIn.Application.ActiveWindow.ActivePane.ViewType == PpViewType.ppViewHandoutMaster; 
                }
                catch
                {
                    return false;
                }
            }

    The long version:

    We have a ppt VSTO 2010 addin and placed a ribbon at "TabHome" (no insertBeforeMso or similar.)

    With our addin ppt 2010 crashes if you call Ribbon.Invalidate() when you close the presentation and you are in any master view (handout master, slide master etc.).

    We called ribbon.Invalidate() in PresentationClose Event and WindowsActivate event, both get called during the close routine. We have to call these methods because like said before it is possible to close only the presentation with ppt staying open. If you have some dynamic data which is displayed in the ribbon you have to invalidate the ribbon during close otherwise it will show the informations of the closed ppt.

    Maybe this helps someone :)

     



    Regards Mark


    Thursday, April 17, 2014 11:24 AM
  • I had the same problem with Powerpoint 2010. Once I touched "Ribbon.Invalide()" each close operation inside the master-view will crash powerpoint.  

    My solution:

    If the master view is active just switch to the normal PowerPoint Slide View. Code (but we are using NetOffice, but the same could should nearly work with VSTO)

                powerpointApplication.PresentationCloseEvent += pres =>
                {
                    if (IsMasterActive(pres))
                    {
                        pres.Application.ActiveWindow.ViewType = PpViewType.ppViewSlide;
                    }
                };

    Thursday, May 7, 2015 1:48 PM

All replies

  • Hello,

    I suppose the issue relates to the way you call the Refresh method, not to the XML itself. To check this, just comment out the AddHandler statement. Does the issue persist?


    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, May 10, 2012 1:06 PM
  • Hello Andrei,

    The issue doesn't persist if i comment out the AddHandler statement.

    It is not the XML itself, but you must declare one or more callback to get the issue.

    Powerpoint doesn't crash when calling Refresh, but on closing the Application once Refresh whas called.

    Thank you.

    Thursday, May 10, 2012 1:39 PM
  • Hi Avlin67,

    I don't think this is a bug. In my opinion, In Office 2010 RibbonUI instance will be deleted. So you will get exception via your code. And I noticed that RibbonUI will not be deleted in Office 2007. It think it just the different option between these Office version.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, May 16, 2012 6:07 AM
    Moderator
  • Hi Tom,

    Thanks for your response. PowerPoint fails within native code after some VB code being executed using VSTO. The bug doesn't happen on code execution but later.

    Did you manage to reproduce the bug ? you can use another Window* (WindowActivate for example  event than Presentation Close by putting insertBeforeMso attribute. (I have updated my first post)

    I doesn't know how detect if Ribbon is ready or not to call his Invalidate sub.

    Read carefully following statements :

    - I can reproduce the issue with anyApplication.Window* events or with theapplication.presentationClose event, even if the events are not fired when users closes PowerPoint

    - If you remove the insertBeforeMso tag from the Xml, the bug disappears, except if you use the application.presentationClose event

    Thanks for your time !


    • Edited by Avlin67 Wednesday, May 16, 2012 9:32 AM
    Wednesday, May 16, 2012 9:27 AM
  • Hi Avlin67,

    I'm not able to reproduce your issue completely, the PptRibbon.ribbon alway has null value without insertBeforeMso. I means that not only has insertBeforeMso but also has no insertBeforeMso same result will receive on PowerPoint 2010. So I think there might be some different logic will use to handle ribbon between Office 12 and Office 14. It doesn't seem a bug.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, May 17, 2012 2:18 AM
    Moderator
  • Hi Tom

    I do not understand, since i manage to reproduce the bug on all Office 2010 installed in my company.

    Installed version is 14.0.6111.5000 SP1 MSO 14.0.6112.5000

    Please see screen below, taken after click on PowerPoint's close button.

    Friday, May 18, 2012 8:28 AM
  • Hi Avlin,

    I couldn't reproduce the issue. Refresh works good. I used the ribbon xml and code that you provided. Do you have any other add-ins installed for PowerPoint 2010? Please try disabling them as there could be some conflict.

    Thanks,


    Shiv Khare

    Tuesday, May 22, 2012 8:12 PM
    Moderator
  • Hi

    There are no other AddIn loaded.

    Can you try on a PowerPoint 2010 AddIn project using .Net 4.0 ? there are no app crash using .net 3.5


    Thanks for your help

    Friday, June 15, 2012 3:10 PM
  • Hi Avlin,

    I could see the crash after calling Refresh from PresentationClose event handler. However UI change is not expected (by calling invalidate) while closing so this doesn't seems a valid case. We shouldn't be changing the UI while closing.

    I tried to reproduce the issue using windowActivate event but that doesn't reproduce. Could you share the steps to reproduce the issue using windowActivate event?

    Thanks,


    Shiv Khare

    Monday, June 18, 2012 6:57 PM
    Moderator
  • Hi Shiv kh

    If you remove the insertBeforeMso tag from the Xml, the bug disappears, except if you use the application.presentationClose event. So test this with inseBerforeMso

    The GetLabel is required in both case to reproduce the crash.

    For your convenience i put rewrite the critical code below :

    In the Ribbon

        Public Sub Refresh()
            Ribbon.InvalidateControl("MyTab")
        End Sub

    In thisAddin.vb

        Private Sub ThisAddInStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup

            AddHandler Application.PresentationClose, AddressOf myRibbonHost.Refresh

        End Sub

    In content into Ribbon.XMl

    <?xml version="1.0" encoding="UTF-8"?>
       
    <customUI onLoad="RibbonLoad" xmlns="http://schemas.microsoft.com/office/2006/01/customui" >
            <
    ribbon>
                <
    tabs>
                            <tab id="MyTab" getLabel="GetLabel" insertBeforeMso="TabHome"/>
                </tabs>
            </
    ribbon>
        </
    customUI>

    PS: It seems to me that calling refresh on presentation close is perfectly valid.

    If the active presentation is the only one, you can close it while keeping the application window. In this case there is no active presentation and we need to disable most of our buttons.

    It is however true, that if the application is being closed, we call refresh for no reason... But I don't see how to detect which situation is happening.

    Tuesday, June 19, 2012 7:51 AM
  • Sorry to bring up this old thread, but we also had this problem.

    In short: We solved this issue by evading calls to Ribbon.Invalidate() if ppt is in Master view.

    if (_ribbon != null && !IsMasterActive())
           _ribbon.Invalidate();
    
    private bool IsMasterActive()
            {
                try{
                    return Globals.ThisAddIn.Application.ActiveWindow.ActivePane.ViewType == PpViewType.ppViewSlideMaster ||
                        Globals.ThisAddIn.Application.ActiveWindow.ActivePane.ViewType == PpViewType.ppViewTitleMaster ||
                        Globals.ThisAddIn.Application.ActiveWindow.ActivePane.ViewType == PpViewType.ppViewNotesMaster ||
                        Globals.ThisAddIn.Application.ActiveWindow.ActivePane.ViewType == PpViewType.ppViewHandoutMaster; 
                }
                catch
                {
                    return false;
                }
            }

    The long version:

    We have a ppt VSTO 2010 addin and placed a ribbon at "TabHome" (no insertBeforeMso or similar.)

    With our addin ppt 2010 crashes if you call Ribbon.Invalidate() when you close the presentation and you are in any master view (handout master, slide master etc.).

    We called ribbon.Invalidate() in PresentationClose Event and WindowsActivate event, both get called during the close routine. We have to call these methods because like said before it is possible to close only the presentation with ppt staying open. If you have some dynamic data which is displayed in the ribbon you have to invalidate the ribbon during close otherwise it will show the informations of the closed ppt.

    Maybe this helps someone :)

     



    Regards Mark


    Thursday, April 17, 2014 11:24 AM
  • I had the same problem with Powerpoint 2010. Once I touched "Ribbon.Invalide()" each close operation inside the master-view will crash powerpoint.  

    My solution:

    If the master view is active just switch to the normal PowerPoint Slide View. Code (but we are using NetOffice, but the same could should nearly work with VSTO)

                powerpointApplication.PresentationCloseEvent += pres =>
                {
                    if (IsMasterActive(pres))
                    {
                        pres.Application.ActiveWindow.ViewType = PpViewType.ppViewSlide;
                    }
                };

    Thursday, May 7, 2015 1:48 PM