Callback when file menu in office 2010 is opened
-
Donnerstag, 8. März 2012 09:53
Hi
Is it possible to get any callback when a user clicks the file menu in office 2010, word and powerpoint?
Thanks in advance,
Martin
Alle Antworten
-
Freitag, 9. März 2012 02:51Moderator
Hi Martin,
Thank you for posting.
You can use the Backstage's onShow attribute to get the callback, please refer to the following ribbon xml and callback:
<?xml version="1.0" encoding="UTF-8"?> <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load"> <backstage onShow="OnShowCallBack"> <tab id="testArea" label="Sample" insertAfterMso="TabInfo" visible="true" > <firstColumn> <group id="grpOne" label="Group One"> <primaryItem> <button id="btnButton" label="Button" imageMso="BevelShapeGallery" /> </primaryItem> <topItems> <layoutContainer id="layoutOne" layoutChildren="vertical"> <editBox id="ebox1" label="Edit Box" alignLabel="topRight" /> <button id="btnButton1" label="Button" imageMso="BevelShapeGallery" isDefinitive="true" /> <editBox id="ebox2" label="Edit Box" /> </layoutContainer> </topItems> </group> <group id="grpTwo" label="Group Two" > <primaryItem> <menu id="menuOne" label="Drop Down Menu"> <menuGroup id="menuGrpOne" > <button id="menuButtonOne" label="Menu Button" /> <button id="menuButtonTwo" label=" Menu Button" /> <checkBox id="chkBox" label="CheckBox" /> </menuGroup> </menu> </primaryItem> <topItems> <editBox id="ebox3" label="Edit Box"/> </topItems> </group> </firstColumn> </tab> </backstage> </customUI>public void OnShowCallBack(object contextObject) { System.Windows.Forms.MessageBox.Show("OnShow"); }Hope this can help you and just feel free to follow up after you have tried.
Best Regards,
Bruce Song [MSFT]
MSDN Community Support | Feedback to us
- Als Antwort markiert Bruce SongModerator Montag, 12. März 2012 03:59
-
Freitag, 9. März 2012 07:59
Hi Bruce. What I can't find any information on is how to have one PowerPoint project which adds a group and a button to the ribbons insert menu, AND that's customize the backstage view.
I tried to add the backstage tag on the same level as the <ribbon> and the <command> tag, but that didn't work at all. I couldn't see my menu item om the ribbons insert tab anymore. Below is a sample of how I did it:
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <backstage onShow="onShowBackstageMenu"></backstage> <commands> <command idMso="ViewNormalViewPowerPoint" onAction ="NormalView_click"/> <command idMso ="ViewSlideSorterView" onAction="SorterView_click"/> <command idMso ="ViewSlideShowReadingView" onAction="ReadingView_click"/> <command idMso ="ViewNotesPageView" onAction="NotesView_click"/> <command idMso ="ViewSlideMasterView" onAction="MasterView_click"/> <command idMso ="ViewHandoutMasterView" onAction="HandoutMasterView_click"/> <command idMso ="ViewNotesMasterView" onAction="NotesMasterView_click"/> </commands> <ribbon> <tabs> <tab idMso="TabInsert"> <group id="myGroup" label="Hello" getVisible="btnInsertVisible"> <toggleButton id="btnInsert" onAction="btnInsertClick" getPressed="btnInsertPressed" getImage="btnInsertGetImage" label="my button" size="large" /> </group> </tab> </tabs> </ribbon> </customUI>
So, is it somehow possible to have the <backstage> tag in the same xml as the <commands> and <ribbon>? If not, do I have to create a new addin just for the onShow callback?
-
Freitag, 9. März 2012 09:16
I came across this page and saw that the <ribbon> and <backstage> was arranged with the <backstage> at the end. And this made it work!
I also saw that the intellisense in the xml file shows which tags you can insert after one and each of them. Beginning with <backstage> tag you can't add ribbon or commands, but if you start with commands and ribbon, then you can add backstage at the end.
- Als Antwort markiert Bruce SongModerator Montag, 12. März 2012 03:59

