【问题标题】:Programmatically exit Backstage View以编程方式退出后台视图
【发布时间】:2014-04-16 21:31:23
【问题描述】:

我们有一个backstage extensionintegrates with the TabSave idMso文件-->另存为)。

我们遇到的问题是,当我从后台单击按钮时 - 我不知道如何关闭后台视图。

我想出的最佳解决方案不是很健壮,所以我希望有人能有更好的方法来处理这个问题,因为关闭后台视图似乎相当直观。也许我错过了一些东西 - 但是一旦我的按钮触发,我就无法退出后台视图。

功能区 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>

功能区回调

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

【问题讨论】:

    标签: c# excel vsto office-2013


    【解决方案1】:

    看起来解决方案是not publicized well - 按钮上有一个标志 (isDefinitive),一旦单击按钮就会自动关闭后台视图 - 而不是在操作完成时。

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

    From MSDN:

    关闭 Backstage 视图并返回到当前工作簿 通过在 自定义 UI XML。

    【讨论】:

      【解决方案2】:

      怎么样:

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

      问候,约尔格

      【讨论】:

        猜你喜欢
        • 2016-07-22
        • 1970-01-01
        • 2016-01-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多