以编程方式退出Backstage视图
我们有一个与TabSave
idMso ( 文件 – >另存为 ) 集成的后台扩展 。
我们遇到的问题是,当我从后台单击一个button – 我不知道如何closures后台视图。
我提出的最好的解决scheme不是很强大,所以我希望有人会有更好的方法来处理这个问题,因为closures后台视图看起来非常直观。 也许我错过了一些东西 – 但是一旦我的button触发,我不能让后台视图退出。
function区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>
function区callback
public void btnAction(Office.IRibbonControl control) { Excel.Window window = control.Context; MessageBox.Show("custom action triggered"); window.Application.SendKeys("{ESCAPE}"); }
看起来好像解决scheme没有公布得很好 – button上有一个标志( isDefinitive
),一旦button被点击,就会自动closures后台视图,而不是当动作完成时。
<button id="btnCustomAction" style="large" label="Custom Action" imageMso="HappyFace" isDefinitive="true" onAction="btnAction"/>
来自MSDN :
通过在自定义UI XML中设置控件的isDefinitive属性,closuresBackstage视图并返回到当前工作簿。
关于什么:
Microsoft.Office.Core.IRibbonUI.ActivateTab("SomeControlIdOfARibbonTab")
问候,Jörg