Question

We have a backstage extension that integrates with the TabSave idMso (File-->SaveAs).

The issue we're having is that when I click a button from the backstage - I don't know how to close the backstage view.

The best solution I've come up with isn't very robust, so I was hoping someone would have a better approach for dealing with this as it seems fairly intuitive to close the backstage view. Maybe I'm missing something - but I can't get the backstage view to exit once my button fires.

Ribbon XML

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <backstage>
        <tab idMso="TabSave">
            <firstColumn>
                <taskFormGroup idMso="SaveGroup">
                    <category idMso="Save">
                        <task id="customTask" label="Custom Task" imageMso="HappyFace">
                            <group id="customGroup1" label="Custom Group">
                                <topItems>
                                    <labelControl id="lblInfo" label="Click to trigger custom action."/>
                                    <button id="btnCustomAction" style="large" label="Custom Action" imageMso="HappyFace" onAction="btnAction"/>
                                </topItems>
                            </group>
                        </task>
                    </category>
                </taskFormGroup>
            </firstColumn>
        </tab>
    </backstage>
</customUI>

Ribbon Callbacks

public void btnAction(Office.IRibbonControl control)
{
   Excel.Window window = control.Context;
   MessageBox.Show("custom action triggered");
   window.Application.SendKeys("{ESCAPE}");
}
Was it helpful?

Solution

Looks like the solution is not publicized well - there's a flag (isDefinitive) on the button that automatically closes the backstage view once the button is clicked - not when the action completes.

<button id="btnCustomAction" 
        style="large" 
        label="Custom Action" 
        imageMso="HappyFace" 
        isDefinitive="true"
        onAction="btnAction"/>

From MSDN:

Closing the Backstage view and returning to the current workbook occurs by setting the control's isDefinitive attribute in the custom UI XML.

OTHER TIPS

What about:

Microsoft.Office.Core.IRibbonUI.ActivateTab("SomeControlIdOfARibbonTab")

Regards, Jörg

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top